Globalization in ASP.net MVC (Resource file per Vi

2019-04-12 04:37发布

问题:

What is the best practice for keeping Resource files when it comes to ASP.net MVC globalization ?

For Example, we have order processing system if we try to keep our resource files for domain i.e order.resx, customer.resx, etc

or else we could try to keep resource files per view i.e OrderProcessingView.resx, CustomerView.resx, etc

Common strings such as "Add", "Edit", "Delete" can handle by using common.resx file.

Or Are there any other approaches to keep the resource files ?

We are using some client side rendering (Jquery templates, Kendo templates) also.

回答1:

One of the localizability best practices is to not reuse translations in different contexts. That's because you want to allow the translator to use different translations for one same piece of English text in different contexts. Why? Because different languages have different rules (e.g. depending on gender, an adjective can take a different form) and also because of context-specific constaints such as space limitations (e.g. a translator may be forced to shorten a string to make it fit somewhere, but shouldn't have to when it's not necessary).

For this reason, having one .resx per view is good practice. If you had just one big .resx, it would be hard to determine what view a string goes into (and you'd also be more tempted to reuse strings in different contexts). You'll also typically need a global .resx for the application for anything that is view-independent, which should be rare.



回答2:

We create only 1 big Resource file per language and that's it. Easier to manage.