locked
Get value from language specific resource file without changing the site language RRS feed

  • Question

  • User-1246604461 posted

    I have several local resource files: default.aspx.resx, default.aspx.nl.resx, default.aspx.en.resx

    Now when I'm on the Dutch domain the default.aspx.nl.resx is loaded. But now I want to access the value from default.aspx.en.resx and get the English value belonging to name "title".

    I can now achieve this by changing the current culture server-side, access the value and then change it back, like so:

    Dim culture As CultureInfo = New CultureInfo("en")
    Threading.Thread.CurrentThread.CurrentCulture = culture
    Threading.Thread.CurrentThread.CurrentUICulture = culture
    Dim title as String = GetLocalResourceObject("title")
    culture = New CultureInfo("nl")
    Threading.Thread.CurrentThread.CurrentCulture = culture
    Threading.Thread.CurrentThread.CurrentUICulture = culture
    But is there a better/faster way? Preferably without have to change the culture for the current thread, so I can just define which resource file I want to access and in which language?

    I saw this link: http://msdn.microsoft.com/fr-fr/library/ms149953.aspx
    I don't see any example here, so I don't know how to use it.
    I tried this: GetLocalResourceObject("title", "en"), it doesn't work, since apparently there's no overloaded function like this available. 

    I'm using ASP.NET 4.5

    Tuesday, March 26, 2013 4:58 PM

All replies

  • User-1137493631 posted

    I think by changeing the current culture only the way you can get it...

    Thursday, April 11, 2013 7:41 PM