How to translate Strings from an .resx file? [duplicate]

1

I'm creating a small application in C # and would like to translate it into English, as I intend to publish it and a good part of the target audience speaks English.

Researching, I discovered that I can use Visual Studio's own tools to translate the interface of the developing program, but at no point did I figure out how I could translate strings used internally into code, which will be represented in from the use of the program in the form of messages.

What is the best way to make these strings untranslated without having to modify the code?

A practical example would be, instead of:

MessageBox.Show("Olá mundo!");

Something like:

MessageBox.Show(String.HelloWord);

It's up to the app to choose the language automatically.

    
asked by anonymous 28.07.2014 / 17:07

1 answer

2

You can create multiple resource files ( Resource files ).

Resource files can be used to store strings that will be translated into other languages.

Let's say you have resource file Resource.resx , it will default to Portuguese words.

If you want to add support for the English language, you need to add a resource file Resource.en.resx (this file contains exactly the keys as the Portuguese file, but the values will be the translated in English) in the same directory.

Whenever the system language changes to English, for example, .NET will automatically use the correct resource file. In the same way you can add support for other languages you just want by adding resource file with the correct extension.

Here has an example.

    
28.07.2014 / 17:38