31215

Load Resources for other Language

Question:

I have an application, which works with Resources for translation. This is working great. Now, I have a special requirement. For this, I have to load the resource-dll for another language (for example, the application starts and works with English, then I have to also to load the German-translations) and look into it for a translation.

Is there an easy-way to do this?

Answer1:

You need to load the resourcemanager and If you need the resources for an specific language you will need to ask for them using the specific culture, using:

GetObject(String, CultureInfo)

You can create the culture that you need using:

new CultureInfo(string name)

Or

CultureInfo.CreateSpecificCulture(string name)

Or

CultureInfo.GetCultureInfo(string name)

The name is the culture name: "en" English, "de" German... You can see a full list on the following link: <a href="http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo%28VS.71%29.aspx" rel="nofollow">cultures</a>

Answer2:

using System.Resources; using System.Reflection; Assembly gerResAssembly = Assembly.LoadFrom("YourGerResourceAssembly.dll"); var resMgr = new ResourceManager("StringResources.Strings", gerResAssembly); string gerString = resMgr.GetString("TheNameOfTheString");

Answer3:

You can make it, with the <a href="http://msdn.microsoft.com/en-us/library/bsb0cfet%28v=vs.110%29.aspx" rel="nofollow">GetString</a> calling the together with the specific <a href="http://msdn.microsoft.com/en-us/library/system.globalization.cultureinfo%28v=vs.110%29.aspx" rel="nofollow">CultureInfo</a> you need. for example:

using System.Resources; using System.Reflection; Assembly gerResAssembly = Assembly.LoadFrom("YourGerResourceAssembly.dll"); var resMgr = new ResourceManager("StringResources.Strings", gerResAssembly); // for example german: string strDE = resMgr.GetString("TheNameOfTheString", new CultureInfo("de")); // for example spanish string strES = resMgr.GetString("TheNameOfTheString", new CultureInfo("es"));

`

Recommend

  • Hive jobs occurs mapreduce error : Call From hmaster/127.0.0.1 to localhost:44849 failed on connecti
  • Get all resources in array
  • apache-spark 1.3.0 and yarn integration and spring-boot as a container
  • .resx files for localization with managed C++
  • php mcrypt equivalent for sagepay on a windows server
  • Access MS-Word spell-checker from (unmanaged) C++
  • Sublime only opens in Sublimerge view
  • How to Create a CSV file using PHP (and upload it)
  • localizable.strings - works in simulator but not on device
  • Excel VBA: search a string to find the first non-text character
  • using localization in cakephp
  • The value of my function is undefined
  • Nuget Assembly reference Microsoft Owin after upgrade to 3.0.1
  • Using C++ templating for SFML Resource Manager
  • VS2013 Build Definition 'Microsoft.TeamFoundation.Client.BasicAuthCredential' is not marke
  • TryParse double values
  • How to use get all NSLocalization using genstrings while preserved current translations
  • Gephi's java default method not implemented in C# with an ikvm-from dll library
  • Activation error occured while trying to get instance of type LogWriter, key “”
  • Inconsistent date time format for German locale
  • Jquery autocomplete with php as remote source: how to append second variable from input to source
  • How do I create an image and save it for later to draw as texture in XNA?
  • What is the equivalent of Android permissions in iOS development? [duplicate]
  • jersey/tomcat Description The origin server did not find a current representation for the target res
  • Synchronize windows folders
  • Bash if statement with multiple conditions
  • Android changing fragment order inside FragmentPagerAdapter
  • Jquery popup on mouse over of calendar control
  • I18n locale disregarding fallbacks
  • JBoss External Properties Files in Classpath
  • How do I get HTML corresponding to current DOM tree?
  • How to create a file in java without a extension
  • Excel - Autoshape get it's name from cell (value)
  • Adding custom controls to a full screen movie
  • Comma separated Values
  • Matrix multiplication with MKL
  • Error creating VM instance in Google Compute Engine
  • CSS Applying specific rule for a specific monitor resolution with only CSS is posible?
  • Hits per day in Google Big Query
  • What are the advantages and disadvantages of reading an entire file into a single String as opposed
  • how does django model after text[] in postgresql [duplicate]
  • Converting MP3 duration time