How to convert a C # .NET application to support multiple languages?

I have a C # application that I need to convert to support English and Spanish, is there an easy way to add this and add other languages ​​later?

+4
source share
3 answers

Yes! It was called resource files (.resx). What you do is:

  • Change the Localizable property of your localizable forms to true . This will force the designer to extract text and other properties from .resx files instead of hard coding.
  • Create your program in one language, say, in English.
  • Then change all your forms to another language:
    • Change the Language property of the form to another language, say Spanish.
    • Change the text on all your controls. The designer will automatically generate a new .resx file for the language.
    • If necessary, turn back and forth.
  • When publishing, go to Assembly Settings and change the language. You can also change the language in the code, I think.

And voila! Everything is ready!

+8
source

You mark all your forms and controls as localizable. This will put all the text associated with the user interface (labels, etc.) in the resource files. If you need to create strings in your code, you use string resource files and view the string with the resource key (for example, StringResource.Get("My_Message") ). Then you can use the tool to translate all of your resources. Typically, you create a localized DLL for each language. We use Passolo for this, but there are other tools.

0
source

You can make a multilingual application in two ways:

  • By making the application Localizable, therefore, when the user changes the culture of the device, the application will automatically switch to the user interface for the culture if you add this language already to the supported languages ​​in the application. You can accomplish this by setting the Localizable property for each form in the Localizable project, and then changing the user interface to a new culture.

  • Using the language parameter and the resource file (.resx) for each added language in your application, and depending on the selected language, you can load images or lines from the selected language resource file.

0
source

Source: https://habr.com/ru/post/1385178/


All Articles