0

I have many Winform and the screen objects (e.g. label, button) are in English. I would like to translate all these objects to other language say Spanish. Also, I would like to base on XML files to translate it. For example, the english.xml will be liked

<Form1>
<Label1>Hello</Label1>
<Button1>World</Button1>
</Form1>
<Form2>
...
</Form2>

spanish.xml will be like:

<Form1>
<Label1>Hola</Label1>
<Button1>Mundo</Button1>
</Form1>
<Form2>
...
</Form2>

So, based on the config. If it is english, the Label1 will be shown as "Hello". If it is Spanish, it will be shown as "Hola".

The question is how should I do this translation in vb.net? Should I do this in the Shown Event? Or, should I create custom control for these label, button object and then perform the translation in the custom control? Any other better way?

Thanks for any help.

  • 2
    The best way to do this in .NET is to use string resources with localized .resx files. For example, if your main resource file is resources.resx, then your resource file for Spanish would be resources.es-ES.resx. – Craig Sep 17 '19 at 13:02
  • See [this answer](https://stackoverflow.com/a/35813707/832052) about using Resource files – djv Sep 17 '19 at 15:03

0 Answers0