Juri Strumpflohner
Juri Strumpflohner Juri is a full stack developer and tech lead with a special passion for the web and frontend development. He creates online videos for Egghead.io, writes articles on his blog and for tech magazines, speaks at conferences and holds training workshops. Juri is also a recognized Google Developer Expert in Web Technologies

HowTo: Get localized string different from the current culture

1 min read

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);

Questions? Thoughts? Hit me up on Twitter
comments powered by Disqus