This is all about developing an application which supports multiple languages.
So that, you need two or more resource files as you need. These files hold the translations corresponding to languages.
As shown bellow figure, you can add resource files to your application. (C#.NET 2005).
As in our example, application supports two languages which are Mongolian and English. Therefore we need 2 resource files say, myRes.mn-MN and myRes. Cultural notation of 'Mongolian' is mn-MN.
After that, we need to put translations into corresponding files. English translation to myRes, and Mongolian to another.
Note: myRes (English translation) will be acting as default language, so we don't need any cultural notation such as en-us. Bellow figure shows translations.
Now lets see how to use resource files.
This two lines of code has to be used in order to access and retrieve data from files
mn-MN, it is related to cultural information.
Following lines of code show how to use cultural information.
So, result comes as follows.
So that, you need two or more resource files as you need. These files hold the translations corresponding to languages.
As shown bellow figure, you can add resource files to your application. (C#.NET 2005).
As in our example, application supports two languages which are Mongolian and English. Therefore we need 2 resource files say, myRes.mn-MN and myRes. Cultural notation of 'Mongolian' is mn-MN.
After that, we need to put translations into corresponding files. English translation to myRes, and Mongolian to another.
Note: myRes (English translation) will be acting as default language, so we don't need any cultural notation such as en-us. Bellow figure shows translations.
Now lets see how to use resource files.
using System.Resources; using System.Globalization;
This two lines of code has to be used in order to access and retrieve data from files
CultureInfo culture; ResourceManager rm; private void Form1_Load(object sender, EventArgs e) { rm = new ResourceManager("multilingual.myRes", typeof(Form1).Assembly); } private void radioButton1_CheckedChanged(object sender, EventArgs e) { if (radioButton1.Checked) culture = CultureInfo.CreateSpecificCulture("mn-MN"); else culture = CultureInfo.CreateSpecificCulture(""); try { label1.Text = rm.GetString("name", culture); label2.Text = rm.GetString("pass", culture); button1.Text = rm.GetString("login", culture); button2.Text = rm.GetString("cancel", culture); groupBox1.Text = rm.GetString("language", culture); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
rm = new ResourceManager("multilingual.myRes", typeof(Form1).Assembly);Here we are assigning to file which will be used to. Both name has to be named same name, and about
mn-MN, it is related to cultural information.
Following lines of code show how to use cultural information.
if (radioButton1.Checked) culture = CultureInfo.CreateSpecificCulture("mn-MN"); else culture = CultureInfo.CreateSpecificCulture("");Once either of radio buttons checked, application will be running according to which language is selected. Here, if radioButton1 checked, application is in Mongolian else in English.
label1.Text = rm.GetString("name", culture);
Here, the value of name variable from selected culture returns.So, result comes as follows.
I thought finding a company that will help me provide all the services that all small business need is a tough one. Thank you for enlightening us about Multilingual application.
ReplyDeleteMultilingual web sites
If you need to create multilingual applications, this collaborative localization managament platform might come in handy: https://poeditor.com/
ReplyDelete