HowTo: Get localized string different from the current culture

Localization is a key part of most applications. For this purpose you usually use resource files (property files in Java, actually they are the same) with the according culture extension, like "MyResources.resx" for the default language, "MyResources.de.resx" for German etc...
You can then access your resources by using "GetLocalResourceObject(...)" for resources related to your current UserControl or Webpage/Form or "GetGlobalResourceObject(...)" for resources that are global to your application (App_GobalResources folder) and you'll automatically get the localized object in the current thread culture.

Often however you may have the case where you want to retrieve a resource object in a different culture than the current one. This can be achieve as follows (example for the german culture):
CultureInfo info = CultureInfo.CreateSpecificCulture("de-De");
string localizedString = Properties.Resources.ResourceManager.GetString("BackText", info);
Kindle

Comments

0

Your ad here?