Search code examples
asp.netlocalizationtranslationarabic

Convert asp.net website from English to Arabic


I have developed one ASP.NET website for my client and now he wants the website to translate from English to Arabic. Can anyone help me how to do this? Is there any ASP.NET class or function for this?


Solution

  • Step 1:

    You need to first Add App_LocalResources Folder. As you have tagged asp.net so I am assuming it is Web Application. Right click your root directory and navigate to Add and then navigate to Add ASP.NET Folder and then navigate to App_LocalResources.

    enter image description here

    Step 2:

    Once you have created the folder. Right click on it and add Resource file. For adding resource file right click at App_LocalResources and then navigate to Add and then navigate to New Item there you can Find Resources File.

    enter image description here

    Step 3:

    If you have a page Named Default, than resource file name for English would be Default.aspx.resx for french would be Default.aspx.fr.resx for Arabic it would be Default.aspx.ar.resx. Remember every language will have separate file names.

    enter image description here

    Step 4:

    Now lest suppose if you have label at Default page and it is like <asp:Label ID="lblTest" Text="Test"></asp:Label> then you need to add meta resource key for every element at page like this: meta:resourcekey="lblTestResource1". Remember resource key name can be any thing which you like but ID with Reosource1 is just a trend. so your label would be like: <asp:Label ID="lblTest" Text="Test"meta:resourcekey="lblTestResource1">`.

    enter image description here

    Step 5:

    Now in next step you need to open resource files and you have to insert in string resource key names. You will insert lblTestResource1.Text in string and will insert Test in value and save.

    Step 6:

    Once you are done with this open web.config file and insert <globalization uiCulture="ar" /> under <system.web> section and you are done for Arabic.

    enter image description here

    Note: For Arabic uiCulture is ar