It's pretty simple.
CurrentCulture
is the culture assigned for thread to be used in various culture-specific methods. To example, ToString()
one.
CurrentUICulture
is
used by the Resource Manager to look up culture-specific resources at run time.
By setting both you ensure what all ToString()
works correctly and your form resources are loaded from appropriate satellite.
Regarding usage, you may think to provide user with option to change language. To example, I have native German windows, but I set English culture in it (date format and default culture for console applications), while I speak Russian. Which language do you think I will chose when using your software? =P
By default, either take language chosen in installer (if you have installer in multiple languages and options to change it there) or current Windows user language preferences.
One possible scenario:
Preconditions: application is already localized, satellites are there (if not, read this). I don't like satellites myself, but they are easy to start with.
When application starts, you create a list of available languages (either statically or by enumerating satellites).
string[] Languages = new[] {"en", "fr", "de", "ru"};
Then, if application start for the first time (to example, you have string language
setting and it's by default null
or ""
, this would be a flag what no language is selected yet), you detect default os language
var language = CultureInfo.InstalledUICulture.TwoLetterISOLanguageName; // to ex, "fr"
and if it's in your list, then you set
Thread.CurrentThread.CurrentUICulture =
Thread.CurrentThread.CurrentCulture = new new CultureInfo(language);
Otherwise, if you don't have this language, then use "default" language (to example, "en"). If its done at at the start of your application, then any further constructed and used window will use proper resources.
User should be able to change language. Give him possibility to chose one of available Languages
. In winforms you will have to reload forms after change culture. Easiest solution would be to simply tell user what "software restart is required".