Convert English Language To Arabic In Windows Form Application C#

Here are the steps,

Step 1: Create MDI forms in Windows Forms Application as in the following figure 1,

Create MDI forms
                                                                           Figure 1

Step 2: Make some designs using two menustrips as in the following figure 2,

designs
                                                                              Figure 2

Step 3: Make a new folder named language, then add two resource files, open one resource file and add corresponding Arabic word instead English menu items as in the following figure 3.

resource files
                                                                           Figure 3

Step 4: Open resource 2 file, add corresponding English word instead menus strip as in the following figure 4.

menus strip
                                                               Figure 4

Step 5: Create table on SQL server then update code status to whether English or Arabic and add this code.

Source code:

  1. using System;    
  2. using System.Collections.Generic;    
  3. using System.ComponentModel;    
  4. using System.Data;    
  5. using System.Drawing;    
  6. using System.Linq;    
  7. using System.Text;    
  8. using System.Windows.Forms;    
  9. using System.Resources;    
  10. using System.Globalization;    
  11. using System.Data;    
  12. using System.Data.SqlClient;    
  13. namespace WindowsFormsApplication1    
  14. {    
  15.     public partial class MDIForms : Form    
  16.     {    
  17.         private int childFormNumber = 0;    
  18.     
  19.         public MDIForms()    
  20.         {    
  21.             InitializeComponent();    
  22.         }    
  23.            
  24.         ResourceManager res_man;    
  25.        // ResourceManager res_man1; // declare Resource manager to access to specific cultureinfo    
  26.         CultureInfo cul;    
  27.         private void switch_language()    
  28.         {    
  29.             menuItem1.Text = res_man.GetString("menuItem1", cul);    
  30.             menuItem2.Text = res_man.GetString("menuItem2", cul);    
  31.             menuItem3.Text = res_man.GetString("menuItem3", cul);    
  32.             menuItem4.Text = res_man.GetString("menuItem4", cul);    
  33.             menuItem5.Text = res_man.GetString("menuItem5", cul);    
  34.             menuItem6.Text = res_man.GetString("menuItem6", cul);    
  35.             menuItem7.Text = res_man.GetString("menuItem7", cul);    
  36.             menuItem8.Text = res_man.GetString("menuItem8", cul);    
  37.             menuItem9.Text = res_man.GetString("menuItem9", cul);    
  38.             menuItem10.Text = res_man.GetString("menuItem10", cul);    
  39.             menuItem11.Text = res_man.GetString("menuItem11", cul);    
  40.             menuItem12.Text = res_man.GetString("menuItem12", cul);    
  41.             menuItem13.Text = res_man.GetString("menuItem13", cul);    
  42.             menuItem14.Text = res_man.GetString("menuItem14", cul);    
  43.             menuItem15.Text = res_man.GetString("menuItem15", cul);    
  44.             menuItem16.Text = res_man.GetString("menuItem16", cul);    
  45.             menuItem17.Text = res_man.GetString("menuItem17", cul);    
  46.             menuItem18.Text = res_man.GetString("menuItem18", cul);    
  47.             menuItem19.Text = res_man.GetString("menuItem19", cul);    
  48.             menuItem20.Text = res_man.GetString("menuItem20", cul);    
  49.             menuItem21.Text = res_man.GetString("menuItem21", cul);    
  50.             menuItem22.Text = res_man.GetString("menuItem22", cul);    
  51.             menuItem23.Text = res_man.GetString("menuItem23", cul);    
  52.             menuItem24.Text = res_man.GetString("menuItem24", cul);    
  53.             menuItem25.Text = res_man.GetString("menuItem25", cul);    
  54.     
  55.             menuItem27.Text = res_man.GetString("menuItem27", cul);    
  56.             menuItem28.Text = res_man.GetString("menuItem28", cul);    
  57.             menuItem29.Text = res_man.GetString("menuItem29", cul);    
  58.             menuItem30.Text = res_man.GetString("menuItem30", cul);    
  59.             menuItem31.Text = res_man.GetString("menuItem31", cul);    
  60.             menuItem32.Text = res_man.GetString("menuItem32", cul);    
  61.                }    
  62.            
  63.         private void CloseAllToolStripMenuItem_Click(object sender, EventArgs e)    
  64.         {    
  65.             foreach (Form childForm in MdiChildren)    
  66.             {    
  67.                 childForm.Close();    
  68.             }    
  69.         }    
  70.         //string GetConStr();//***************** add sql connection    
  71.         private void logOutToolStripMenuItem_Click(object sender, EventArgs e)    
  72.         {    
  73.             //SqlConnection conn = new SqlConnection(GetConStr());    
  74.     
  75.             //conn.Open();    
  76.             //SqlCommand cmd = new SqlCommand("UPDATE  Language  SET status='Arabic' WHERE status='English' ", conn);    
  77.             //cmd.ExecuteNonQuery();    
  78.             res_man = new ResourceManager("WindowsFormsApplication1.language.Resource"typeof(MDIForms).Assembly);    
  79.     
  80.             cul = CultureInfo.CreateSpecificCulture("Ar");    
  81.             switch_language();    
  82.             menuStrip.Font = new Font("Segoe UI", 12, FontStyle.Regular);    
  83.             menuStrip1.RightToLeft = RightToLeft.No; ;    
  84.             menuStrip.Dock = DockStyle.Right;    
  85.         }    
  86.     
  87.         private void eNGLISHToolStripMenuItem_Click(object sender, EventArgs e)    
  88.         {    
  89.             //SqlConnection conn = new SqlConnection(GetConStr());    
  90.     
  91.             //conn.Open();    
  92.             //SqlCommand cmd = new SqlCommand("UPDATE  Language  SET status='English' WHERE status='Arabic' ", conn);    
  93.             //cmd.ExecuteNonQuery();    
  94.             res_man = new ResourceManager("WindowsFormsApplication1.language.Resource"typeof(MDIForms).Assembly);    
  95.     
  96.             cul = CultureInfo.CreateSpecificCulture("en");    
  97.             switch_language();    
  98.             menuStrip.Font = new Font("Segoe UI", 12, FontStyle.Regular);    
  99.             menuStrip1.RightToLeft = RightToLeft.Yes; ;    
  100.             menuStrip.Dock = DockStyle.Left;     
  101.         }    
  102.     }    
  103. }  
The output will be as in the following figure 5,

run
                                                                                 Figure 5

Step 6: We can design child form for sample Arabic conversion by adding new form, add some labels and controls as in the following figure 6,

design
                                                                                       Figure 6

Source code for change language child form:
  1. using System;    
  2. using System.Collections.Generic;    
  3. using System.ComponentModel;    
  4. using System.Data;    
  5. using System.Drawing;    
  6. using System.Linq;    
  7. using System.Text;    
  8. using System.Windows.Forms;    
  9. using System.Resources;    
  10. using System.Globalization;    
  11. using System.Data;    
  12. using System.Data.SqlClient;    
  13. namespace WindowsFormsApplication1    
  14. {    
  15.     public partial class Form1 : Form    
  16.     {    
  17.         public Form1()    
  18.         {    
  19.             InitializeComponent();    
  20.         }    
  21.         string activation_status = "English";     
  22.         private void switch_language()    
  23.         {    
  24.             label2.Text = "??? ??????";    
  25.             label3.Text = "??? ????";    
  26.             label23.Text = " ???? ????";    
  27.             label4.Text = "???";    
  28.             label5.Text = "??? ???????";    
  29.             label6.Text = "???";    
  30.             label7.Text = "????? ?????";    
  31.             label8.Text = "????? ????????";    
  32.             button8.Text = "???";    
  33.             btnClear.Text = "????";    
  34.             btnClose.Text = "?????";    
  35.             panel1.Dock = DockStyle.Right;    
  36.             panel3.Dock = DockStyle.Right;    
  37.             panel2.Dock = DockStyle.Right;    
  38.             }    
  39.        // public string activation_status;    
  40.         //public void checkactivation()    
  41.         //{    
  42.         //    //ConnectionsDL objcon = new ConnectionsDL();    
  43.         //    //string constr = objcon.GetConString();    
  44.     
  45.         //  SqlConnection conn = new SqlConnection(GetConStr());    
  46.     
  47.         //    conn.Open();    
  48.         //    SqlCommand cmd = new SqlCommand("select * from Language", conn);    
  49.         //    cmd.ExecuteNonQuery();    
  50.         //    SqlDataAdapter daLogin = new SqlDataAdapter(cmd);    
  51.         //    DataSet dsLogin = new DataSet();    
  52.         //    daLogin.Fill(dsLogin);    
  53.         //    DataTable actTable = new DataTable();    
  54.         //    actTable = dsLogin.Tables[0];    
  55.     
  56.         //    for (int i = 0; i < actTable.Rows.Count; i++)    
  57.         //    {    
  58.         //        activation_status = actTable.Rows[i]["status"].ToString().Trim();    
  59.         //    }    
  60.         //}    
  61.         ResourceManager res_man;    
  62.                CultureInfo cul;    
  63.         public void langugechange()    
  64.         {    
  65.             //checkactivation();    
  66.             if (activation_status == "Arabic")    
  67.             {    
  68.             switch_language()    
  69.             }    
  70.             else if (activation_status == "English")    
  71.             {    
  72.                     
  73.             }    
  74.            
  75.         }    
  76.     
  77.         private void Form1_Load(object sender, EventArgs e)    
  78.         {    
  79.             langugechange();    
  80.         }    
  81.    }    
  82. }  
The output will be as in the following figure 7. You can change language activation status in SQL server (now I am giving it directly).

output
                                                                                    Figure 7

Summary

In this article, we discussed how to convert English language to Arabic language in Windows Form C#. After that, we discussed how to use its various properties and methods to build real middle east world application.