I need to be able to display language specific UI text when a user uses the application. Currently I am storing the text in a Properties.Settings file for each language. Is there any way to create a variable that points to the settings file so that I just set this variable to point to the selected language settings file and the application then uses this variable to retrieve the required text strings.
Using Properties.Settings.Default.textString means I have to do something like the following:
if (language == "English") {
String text = Properties.SettingsEnglish.Default.textString;
} else
if (language == "SomethingElse") {
String text = Properties.SettingsSomethingElse.Default.textString;
}
I would prefer doing something like this because it would require only performing the check only once:
Properties varSettings;
if (language == "English") {
var = Properties.SettingsEnglish;
} else
if (language == "SomethingElse") {
var = Properties.SettingsSomethingElse;
}
...
String text = varSettings.Default.textString;
Any suggestions on the best way to do this - bearing in mind this must be a user selectable application option rather than a OS level language specific install option.
.Net applications already have a powerful localization mechanism built in, discussed at How to use localization in C#. To summarise:
Thread.CurrentThread.CurrentUICulture
to the desired culture.Do not forget non-string localization aspects like time and date formats, too.
For an overview, see http://msdn.microsoft.com/en-us/library/h6270d0z(v=vs.110).aspx.