Search code examples
c#winformstext-filestranslate

Translating Form


I have to translate a program in other languages. Currently I use text files that contain translated words on different rows and read from them for every menu in the program.This way the user can just switch the words in the files and it will translate the program.But I've got some problems doing it that way. Is there an easier way to translate a program?


Solution

  • It's a little too broad a topic to provide specific code examples of how you can do this in C# with Windows Forms but I'll try to give you some context on how .NET supports localization in desktop apps.

    .NET contains the System.Globalization namespace which itself contains properties that manage the culture in which your application resides. You could leverage this to allow users to change the language of controls on your forms by changing the Culture.

    Here is a pretty good example of how somebody has used this functionality to automatically localise controls on a form. https://www.dotnetcurry.com/showarticle.aspx?ID=174

    They essentially expose a 'ChangeLanguage' method which changes the local Culture and then loops through each of the controls on the form, translating them to the selected language.