Question

I am working in maintenance windows form app project. Till now project is only in one language. Language text is managed by a resource file generated by StronglytypedResourceBuilder. Now I need to add other languages.

Using run custom tool(StronglytypedResourceBuilder) on resource file, my English language resource file generated as Home.resx and its Designer file Home.designer.resx file with Home as class name.

Now the problem is, if I create file for Spanish language as Home.es-ES.resx and run the custom tool to create its designer file it is not generating the class file because I think in this case it will try to generate with same class name Home.cs that is not possible.

If I generate file with HomeES.resx then its designer class file will be generated with HomeES as class name.

In code resources are used as Resources.Localization.Home.title at so many places. Now in this case if i have to use resources of HomeES file then i have to use it as Resources.Localization.HomeES.title and i have to put condition at each every place in code to use resource according to culture that is not feasible.

Problem is critical to explain :D, I hope you understand the scenario.

Was it helpful?

Solution

One class enough. Make sure that Access modifier set to the Friend or Public.
At run time resources will be used based on the current culture automatically.

If CultureInfo = "es-ES" then title value from resource file which named as "Home.es-ES.resx will be used.

MSDN Resources and Localization

Using Resources for localization

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top