Tuesday 15 July 2014

.net - C#: How to get a resource string from a certain culture -


I have a resource conference with translated texts in different languages, like the project looks like this:

< Ul>
  • FooBar.resx
  • FooBar.nb-NO.resx
  • FooBar.sv-SE.resx
  • ...
  • I can get the texts using the static properties like this:

      var value = FooBar.Hello;  

    Or using reflection like this:

      var value = resource assembly. Gate type ("nomenclature fubar"). GetProperty ("Hello") .GetValue (empty, zero) as string;  

    In both ways, I will get the value associated with the existing UI culture of the current thread. Which is fine and completely what I would normally like.

    But can I do something if I want to explicitly believe in Swedish, without changing the UI culture?

    You can manually change the property of the Fübre class which is Visual Studio produces or if you are using directly, you can use the surcharge which takes the desired culture as a parameter.


    No comments:

    Post a Comment