Reputation: 197
I am creating an bilingual ASP.NET MVC application. As I know there are two ways to make it bilingual :
First option is to use resource files. If I would use it resources I would need now about 20 fields. If application grows (this might happen, of course :) ) I will need it more and more fields. But this solution I believe is quite flexible solution.
Second option is to create separate view files (for example: Index.aspx, Index.en.aspx..). If there will be more than one or two languages it can become messy (I would have a lot of files). Otherwise, I wouldn't need to worry if translation is made correct or not.
My question is which choice would be more useful (or have more advantages) ? What do you think would be advantages and disadvantages of using one or another option? Also, if I would decide to use separate pages, where/how I should define which one of pages to load ? Maybe there is even better option to make bilingual application?
Upvotes: 0
Views: 1324
Reputation: 33149
Using resources is not only less work, it also makes sure your UI remains consistent across languages (if that is what you want). All you need to do is make sure you have the same resources per language, and you're all set, without having to duplicate Views.
Especially for larger projects and non-POC projects, where you can expect a lot of maintenance work, doing double work makes no sense to me -- and Resource files solve that problem.
Upvotes: 1
Reputation: 46018
I would suggest using resources. I use them for a multilingual web app without any problems.
All you need to do is to set CurrentCulture
and CurrentUICulture
on the current Thread
and the framework will pick up a proper file for you.
Also, if you use Data Annotation attributes - there is a support for Resource files there as well.
You will probably find it useful to create a 'common' file with popular strings, ie, OK, Cancel, Save, Yes, No, Today, ...
Upvotes: 2