Last post Jun 08, 2007 08:36 AM by vivek_iit
Jun 07, 2007 05:36 PM|rswetnam|LINK
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"];
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";
btnLanguage.Text = "Version français";
cookie["lang"] = "en-ca";
Any help on how to conditionally load the grid with the appropriate language would be greatly appreciated.
Jun 08, 2007 01:40 AM|TATWORTH|LINK
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
Jun 08, 2007 08:36 AM|vivek_iit|LINK
Simple solution: you can store the current culture in a Session object and load the grid based on that culture value.
Hope this helps,