I have a resource assembly with translated texts in various languages. Project kind of looks like this:
I can get the texts using static properties like this:
var value = FooBar.Hello;
Or by using reflection like this:
var value = resourceAssembly .GetType("Namespace.FooBar") .GetProperty("Hello") .GetValue(null, null) as string;
Both ways will get me the value belonging to the current UI culture of the current thread. Which is fine and totally what I would usually like.
But, is there something I can do if I explicitly want for example the Swedish value, without having to change the UI culture?
Try the following code. It worked fine for me at least:
FooBar.ResourceManager.GetString("Hello", CultureInfo.GetCultureInfo("sv-SE"))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With