Single stepping throught I see that: the page culture and uiCulture are = "Cymraeg (y Deyrnas Unedig)".
I think this is wrong and it should be "cy-GB"
The the thread culture and uiCulture are "cy-GB"
The lines:
UICulture = threadUICult;
Culture = threadCult;
do nothing.
UICulture and Culture do not get set to "cy-GB" but remain "Cymraeg (y Deyrnas Unedig)" I'm wondering if this is why I'm not getting Welsh emitted onto my page. "Cymraeg (y Deyrnas Unedig)" (which is the description) isn't a valid culture and doesn't match
against the resource culture.
The question is, why does the page culture seem to be being set to the culture description instead of its name (cy-GB), and why can it not be changed?
Eponymous Co...
0 Points
1 Post
Cannot get localization to work
Jun 08, 2011 03:01 PM|LINK
web.config configured with :
Default.aspx as follows:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ResTest._Default" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head runat="server"> <title></title> </head> <body> <asp:Localize id="test" runat="server" meta:resourcekey="Test_String"/> </body> </html>Two resx files in App_LocalResources:
Both have Test_String.Text defined
I can only ever see the "default" text, irrespective of browser localisation.
Tried the following in Page_Load() as a test
protected void Page_Load(object sender, EventArgs e) { string txt1 = System.Threading.Thread.CurrentThread.CurrentUICulture.ToString(); string txt2 = System.Threading.Thread.CurrentThread.CurrentCulture.ToString(); string txt = ( txt1 + " : " + txt2 + " : " + this.GetLocalResourceObject("Test_String.Text").ToString()); test.Text = txt; }See the following rendered on the web page (and returned by GetLocalResourceObject in debug:
So getting the right culture, but not getting the right resource.
Added an InitialiseCulture method:
protected override void InitializeCulture() { string curUICult = UICulture; string curCult = Culture; string threadUICult = System.Threading.Thread.CurrentThread.CurrentUICulture.Name; string threadCult = System.Threading.Thread.CurrentThread.CurrentCulture.Name; UICulture = threadUICult; Culture = threadCult; base.InitializeCulture(); }Single stepping throught I see that: the page culture and uiCulture are = "Cymraeg (y Deyrnas Unedig)".
I think this is wrong and it should be "cy-GB"
The the thread culture and uiCulture are "cy-GB"
The lines:
UICulture = threadUICult;
Culture = threadCult;
do nothing.
UICulture and Culture do not get set to "cy-GB" but remain "Cymraeg (y Deyrnas Unedig)" I'm wondering if this is why I'm not getting Welsh emitted onto my page. "Cymraeg (y Deyrnas Unedig)" (which is the description) isn't a valid culture and doesn't match against the resource culture.
The question is, why does the page culture seem to be being set to the culture description instead of its name (cy-GB), and why can it not be changed?
Tamilmani Kp...
Participant
1091 Points
265 Posts
Re: Cannot get localization to work
Jun 09, 2011 03:49 AM|LINK
Efforts Never Fail...
nareshguree2...
Star
11118 Points
1997 Posts
Re: Cannot get localization to work
Jun 10, 2011 06:14 PM|LINK
first you need to check your webconfig file
and set like <globalization culture="en-US" uiCulture="en-US" requestEncoding="utf-8" responseEncoding="utf-8"/>
write code in global .asax file