Get resource string from .NET application regardless of the current culture

It is common practice that for the multilingual .NET application language specific strings are placed on the Resource of the .NET application. Each supported language has itc own resource file which holds the translated strings. Many year ago I wrote article about it, and you can find it on this location (on Bosnian language). But what if you want to get the resource string regardless of you current culture. In fact when you call App.Properties.Resources.SomeString you always the localized string based on the current culture. If you want to get string from other language than current culture, you need to call something else. For example: Suppose your current culture is English, and you want to get string from the German resources. The picture below shows the resource string in both language specific resources (the first one is German, the second is English resource): resources


First you need to create Culture info object for german language, and call the GetString method from ResourceManages class by passing the cultureInfor object. The code below show the procedure of getting the string in other that current application language.

System.Globalization.CultureInfo germanInfo = new CultureInfo("de-DE");
string germanWord= Properties.Resources.ResourceManager.GetString("CompatibleMode", germanInfo);

Happy programming

Posted Nov 12 2014, 11:58 AM by Bahrudin
Filed under: , is a .Net Community Blog powered by daenet GmbH.