Click here to Skip to main content
15,887,027 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi guys I'm trying to import to my web site multilanguage support for three different languages.
I create three .resx files Strings.el-GR.resx, Strings.en-US.resx, Strings.ru-RU.resx.

in my site.master page i import the following code
C#
ResourceManager m;
    CultureInfo ci;
    protected void Page_Load(object sender, EventArgs e)
    {
       if (!IsPostBack)
        {
            Thread.CurrentThread.CurrentCulture = new CultureInfo("en-Us");
            m = new ResourceManager("Resources.Strings", System.Reflection.Assembly.Load("App_GlobalResources"));
            ci = Thread.CurrentThread.CurrentCulture;
            LoadString(ci);
        }
        else
        {
            m = new ResourceManager("Resources.Strings", System.Reflection.Assembly.Load("App_GlobalResources"));
            ci = Thread.CurrentThread.CurrentCulture;
            LoadString(ci);
        }


C#
private void LoadString(CultureInfo ci)
    {
        //localization load correct language from resources
        Search.Text = m.GetString("search", ci);
        welcome_message.Text = m.GetString("welcome_message", ci);
        flag2.Text = m.GetString("flag2", ci);
        shop1.Text = m.GetString("shop1", ci);
        shop2.Text = m.GetString("shop2", ci);
        Advanced_search.Text = m.GetString("Advanced_search", ci);
        //CURRENCY Convertor web service localization
        currcovert.Text = m.GetString("currcovert", ci);
        currencyconvert.Text = m.GetString("currencyconvert", ci);
        convprice.Text = m.GetString("convprice", ci);
        curfrom.Text = m.GetString("curfrom", ci);
        curto.Text = m.GetString("curto", ci);
        curresult.Text = m.GetString("curresult", ci);
        //end currency convertor web service localization
        //google maps
        VisitUs.Text = m.GetString("VisitUs", ci);
        //end google maps
    }

C#
protected void Button2_Click(object sender, EventArgs e)
  {
      Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");
      LoadString(Thread.CurrentThread.CurrentCulture);
  }

  protected void flag4_Click(object sender, ImageClickEventArgs e)
  {
      Thread.CurrentThread.CurrentCulture = new CultureInfo("el-GR");
      LoadString(Thread.CurrentThread.CurrentCulture);
  }
  protected void flag3_Click(object sender, EventArgs e)
  {
      Thread.CurrentThread.CurrentCulture = new CultureInfo("ru-RU");
      LoadString(Thread.CurrentThread.CurrentCulture);
  }


The code works perfect with labes, button texts e.t.c
My question is I have a menu with some items (home,products,shipping,about us) how can i switch these texts to the correct language?
Finnaly I have some other subpages how can i also change their text to the correct cultural info ?

Thnx in advance for your help and your time!
Posted

I import a new site.master.resx
where i import the values like
MenuItemResource1.Text

then for subpages i create resx files for every .aspx for example
about.aspx.es.resx,home.aspx.es.resx
 
Share this answer
 
yup... u just ad a master page in to ur website file through add new item...

then import ur menu bar their... clearly n neatlyy....

finally simply import ur master page in to remaining pages like....

MasterPageFile="masterpageprog.master" {Example}

hope it will help u...
 
Share this answer
 
Comments
JasonTsoum77 30-Oct-13 17:29pm    
Thnx for your response and your help ..it's really annoying-brute force the language localization in asp web site i thought it will be easier but....
satyaanupama 2-Nov-13 0:34am    
yes...tel me about but...? what
I import a new site.master.resx
where i import the values like
MenuItemResource1.Text

then for subpages i create resx files for every .aspx for example
about.aspx.es.resx,home.aspx.es.resx
 
Share this answer
 
Comments
Richard C Bishop 30-Oct-13 17:33pm    
Why did you post this solution twice? You will probably receive abuse reports.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900