locked
Multilingual Grid RRS feed

  • Question

  • User-1503358686 posted

    Hi:

    I have created a bilingual French/English site.  I am able to switch the controls back and forth between the two languages using resource files and cookies.  My database is also bilingual where I have used the convention of naming a field with the _fr suffix if the field is in French - e.g.  title and title_fr. 

    My challenge is to load the appropriate fields into a grid - depending on the selected language.  I suppose I could either use different queries for French and English or user the same query but only make visible in the grid the fields of the selected language.  Any suggestions on how I can conditionally load the data controls would be greatly appreciated.  FYI, here's how I load the page to show in the appropriate language:

     
    protected override void InitializeCulture()
        {
            string lang = "";
            HttpCookie cookie = Request.Cookies["PREFERENCES"];

            if (cookie != null && cookie.Value != null)
                lang = cookie["lang"];
            else
                lang = "fr";

            {
                Thread.CurrentThread.CurrentUICulture = new CultureInfo(lang);
                Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(lang);
            }
        }

       This is how I select the language using a hyperlink button in the Master Page:

    protected void btnLanguage_Click(object sender, EventArgs e)
        {
           
            //TODO - create function
           
            HttpCookie cookie = new HttpCookie("PREFERENCES");
            if (btnLanguage.Text == "Version français")
            {
                btnLanguage.Text = "English";
                cookie["lang"] = "fr-ca";        
            }
            else
            {
                btnLanguage.Text = "Version français";
                cookie["lang"] = "en-ca";
            }
            Response.Cookies.Add(cookie);
            Response.Redirect(Request.UrlReferrer.AbsoluteUri);
        }
     

    Any help on how to conditionally load the grid with the appropriate language would be greatly appreciated.

    Roger Swetnam
     

    Thursday, June 7, 2007 5:36 PM

Answers

  • User-319574463 posted

     Look at http://www.guysmithferrier.com/ and in particular at Guy Smith's book ISBN 0321341384. The book is available online at Safari books at http://safari.oreilly.com/0321341384

    Also his presentation http://www.guysmithferrier.com/downloads/teni18n.pdf

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 8, 2007 1:40 AM
  • User-503940700 posted

    Simple solution: you can store the current culture in a Session object and load the grid based on that culture value.

    Hope this helps,

    Vivek 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 8, 2007 8:36 AM

All replies

  • User-319574463 posted

     Look at http://www.guysmithferrier.com/ and in particular at Guy Smith's book ISBN 0321341384. The book is available online at Safari books at http://safari.oreilly.com/0321341384

    Also his presentation http://www.guysmithferrier.com/downloads/teni18n.pdf

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 8, 2007 1:40 AM
  • User-503940700 posted

    Simple solution: you can store the current culture in a Session object and load the grid based on that culture value.

    Hope this helps,

    Vivek 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, June 8, 2007 8:36 AM