Marthin
Marthin

Reputation: 6543

Change cultureinfo and get correct resx translation

Im trying to use the following code to get translation from my swedish resx but it will only return the english translation from my default resx. I have the translations in both file with the exact same key. I call this from a command line c# program. Anyone know why it will not translate?

public String GetString(String resxPackageName, String xmlKey)
{            
    Thread.CurrentThread.CurrentCulture = new CultureInfo("sv-SE", false);
    ResourceManager rm = new ResourceManager("MyPackage.CustomerPortal.Followup", this.GetType().Assembly);
    return rm.GetString("CurrentPriceTagTranslation");
}

Upvotes: 2

Views: 2162

Answers (1)

Adrian Fâciu
Adrian Fâciu

Reputation: 12552

I think that if you don't specify a culture in GetString method it will use the CurrentUICulture of the calling thread, if you change it everything should work.

Upvotes: 2

Related Questions