1

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?

Freez
  • 7,208
  • 2
  • 19
  • 29
Rizvi
  • 17
  • 1
  • 9

1 Answers1

3

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

Afnan Ahmad
  • 2,492
  • 4
  • 24
  • 44
  • It is very helpful but i want to make one dropdown with 2 option (English,Arabic). So, the page should be translate based on user selection – Rizvi Mar 14 '17 at 11:25
  • 1
    @Rizvi Than you need to find out how on base of selection of drop down value you can change web config `uiCulture` value. – Afnan Ahmad Mar 14 '17 at 13:18
  • Thanks for your help and i got some idea as well from here. – Rizvi Mar 15 '17 at 06:37