Click here to Skip to main content
15,889,909 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I'm struggling with localization. It seems the more I read the more confused I get. I started with a single resource file "strings.resx" in this file, I made my English string assignments.

From inside of VS2012, I couldn't add another string resource file and have it appear in the editor the way I was expecting (in other words, I couldn't add the string constants for the new language).

So, from the filesystem, I copied the original resx to create 2 new string resource files. "strings.fr.resx" and "strings.es.resx". I then added these 2 files to my solution and added the appropriate translation strings to match up to the default resource file.

I set the "Access Modifier" on each to "Internal" and generated the designer.cs files.

One thing that I see different in solution explorer is that the first one I created has a strings class with resource manager, culture and the string constants enumerated. The others do not.

Everything compiles fine, but when I set the strings.resourceCulture to French, I still get the English string value returned.

I'm assuming my approach to copying and renaming the resource file was probably where I went wrong. Please help me get back on the right course.
Posted

This kind of globalization and localization is based on satellite assemblies and fallback. The basic idea is: you globalize the product starting with just one, base culture, using resources, make the UI fluid, so the change of the string lengths won't screw up the layout, take into account different date/time/currency formats, and so on. When your product is ready, you can add localizations by adding satellite assemblies each containing the same set of resources, but only resources, so the localization can be written by another person or a team, even if they have no access to original source code, except those resources.

The system automatically chooses requires localization based on the current thread culture, which you can dynamically switch. If some culture absent from satellites, the fallback mechanism automatically chooses the closest implemented culture.

For further detail, please see my past answers:
How to use a Single resx file for 3 languages[^],
globalization in winforms[^],
globalization/localization problem in winform .net[^].

See also: Globalization of Checkboxes[^].

—SA
 
Share this answer
 
v2
Comments
littleGreenDude 4-Jan-15 15:29pm    
Sergey, thank you for the message. Having separate assemblies seems overly complicated for my needs. I have roughly 10 sentences that need to be represented. When I look at the code that is generated, it looks like if you set the correct resourceCulture it should just use the correct localized string table and return the value for that culture/language.


/// <summary>
/// Looks up a localized string similar to Share.
/// </summary>
internal static string SHARE {
get {
return ResourceManager.GetString("SHARE", resourceCulture);
}
}
Sergey Alexandrovich Kryukov 5-Jan-15 0:24am    
If you don't want to use satellite assemblies, forget localization, period.
Any approach without satellite assemblies will at best make things way more complicated, or even can lead you to failure. No ifs no buts.
—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900