Whenever my current culture is getting is changed based on the URL, my label/literel values are not getting changed,.. the values are always from the en-us language..
This problem araised only in the master page. ive changed weg.config and everything.. :(
<%
@MasterLanguage="C#"
%>
<!
DOCTYPEhtmlPUBLIC"-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%
@ImportNamespace="Microsoft.SharePoint"
%>
.
.
<asp:LiteralID="test"runat="server"Text="<%$Resources:ResourceClass,
test %>"></asp:Literal>
you have to do this, you have to override InitializeCulture on all pages as below
Protected Overrides Sub InitializeCulture()
Dim CultureInfo = New Globalization.CultureInfo(Session["currentCulture"].ToString())
Threading.Thread.CurrentThread.CurrentCulture = CultureInfo
Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo
MyBase.InitializeCulture()
End Sub
i read current culture from Session["currentCulture"] but you can read it from url or from database...
Your marked answers helps other fixing fast...
Cheers!
Tarun Juneja
http://meghainfotech.wordpress.com/
Here the problem is. My current culture is getting changed to the appropriate languages without any issues.. but not able to fetch key values for label/litrel other than english..
do you see i again redirect user to the same page so that localized values are set
Protected Sub SubmitLanguage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SubmitLanguage.Click
SetCulture()
End Sub
Private Sub SetCulture()
Common.Culture = LanguageList.SelectedValue
Dim CultureInfo = New Globalization.CultureInfo(Common.Culture) ' see Common.Culture below
Threading.Thread.CurrentThread.CurrentCulture = CultureInfo
Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo
Response.Redirect(Request.RawUrl) ' load same page again
End Sub
here is my page init code
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs)
Dim CultureInfo = New Globalization.CultureInfo(Common.Culture)
Dim UserIdentityId%
Threading.Thread.CurrentThread.CurrentCulture = CultureInfo
Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo
End Sub
Here is my method to set the culture it is in Common Class, so i call it like Common.Culture
' if no culture is defined it returns english always
Public Shared Property Culture$()
Set(ByVal value$)
HttpContext.Current.Session!Culture = value
End Set
Get
If String.IsNullOrEmpty(HttpContext.Current.Session!Culture) Then
Culture = "en-US"
Return Culture
End If
Return HttpContext.Current.Session!Culture
End Get
End Property
Your marked answers helps other fixing fast...
Cheers!
Tarun Juneja
http://meghainfotech.wordpress.com/
ChandruPerum...
Member
36 Points
13 Posts
Globalization of master page is not working even culture of the master page changes..
Sep 13, 2011 06:50 AM|LINK
Hi,
Whenever my current culture is getting is changed based on the URL, my label/literel values are not getting changed,.. the values are always from the en-us language..
This problem araised only in the master page. ive changed weg.config and everything.. :(
<%
@ Master Language="C#" %>
<!
DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<%
@ Import Namespace="Microsoft.SharePoint" %>
.
.
<asp:Literal ID="test" runat="server" Text="<%$Resources:ResourceClass, test %>" ></asp:Literal>
Please help me regarding this..
Chandru
tarun n june...
Contributor
4054 Points
902 Posts
Re: Globalization of master page is not working even culture of the master page changes..
Sep 13, 2011 07:04 AM|LINK
you have to do this, you have to override InitializeCulture on all pages as below
Protected Overrides Sub InitializeCulture()
Dim CultureInfo = New Globalization.CultureInfo(Session["currentCulture"].ToString())
Threading.Thread.CurrentThread.CurrentCulture = CultureInfo
Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo
MyBase.InitializeCulture()
End Sub
i read current culture from Session["currentCulture"] but you can read it from url or from database...
Cheers!
Tarun Juneja
http://meghainfotech.wordpress.com/
sathish_juk
Participant
1777 Points
361 Posts
Re: Globalization of master page is not working even culture of the master page changes..
Sep 13, 2011 07:06 AM|LINK
http://forums.asp.net/t/1558236.aspx/1?Requirement+to+Develop+a+Multilingual+Website
Sathish Kumar
Mark this post as "ANSWER", if it helped you..
ChandruPerum...
Member
36 Points
13 Posts
Re: Globalization of master page is not working even culture of the master page changes..
Sep 13, 2011 07:14 AM|LINK
i have already initialized the culture..
Here the problem is. My current culture is getting changed to the appropriate languages without any issues.. but not able to fetch key values for label/litrel other than english..
Chandru
tarun n june...
Contributor
4054 Points
902 Posts
Re: Globalization of master page is not working even culture of the master page changes..
Sep 13, 2011 07:34 AM|LINK
if this is the case then surely there is some issue with your resource file naming covention...
can you share one resource file names for multiple languages
Here are my for example
ContactUs.aspx.resx for english
ContactUs.aspx.ru-RU.resx russian
ContactUs.aspx.zh-CN.resx Chinese
Cheers!
Tarun Juneja
http://meghainfotech.wordpress.com/
ChandruPerum...
Member
36 Points
13 Posts
Re: Globalization of master page is not working even culture of the master page changes..
Sep 13, 2011 08:39 AM|LINK
Hi Tarun,
My filename is like
contacts.resx
contacts.en-US.resx
contacts.es-ES.resx.
Its working fine for pages but not for master pages....
Chandru
sathish_juk
Participant
1777 Points
361 Posts
Re: Globalization of master page is not working even culture of the master page changes..
Sep 13, 2011 08:44 AM|LINK
http://forums.asp.net/t/971146.aspx/1?MasterPages+Localization+Globalization+amp+resources+issue
http://www.codeproject.com/KB/aspnet/masterpageglobalization.aspx
Sathish Kumar
Mark this post as "ANSWER", if it helped you..
tarun n june...
Contributor
4054 Points
902 Posts
Re: Globalization of master page is not working even culture of the master page changes..
Sep 13, 2011 08:56 AM|LINK
Master page does not have InitialzeCulture method...so do you set the the Thread culture properly.
E.g.
You can set it on dropdown selected indexd changed or on button click
Cheers!
Tarun Juneja
http://meghainfotech.wordpress.com/
ChandruPerum...
Member
36 Points
13 Posts
Re: Globalization of master page is not working even culture of the master page changes..
Sep 13, 2011 09:03 AM|LINK
Yes tarun..
I had set the culture already and its coming proper... but not values for the corresponding culture is not coming
Chandru
tarun n june...
Contributor
4054 Points
902 Posts
Re: Globalization of master page is not working even culture of the master page changes..
Sep 13, 2011 09:18 AM|LINK
This is my master page code
do you see i again redirect user to the same page so that localized values are set
Protected Sub SubmitLanguage_Click(ByVal sender As Object, ByVal e As EventArgs) Handles SubmitLanguage.Click SetCulture() End Sub Private Sub SetCulture() Common.Culture = LanguageList.SelectedValue Dim CultureInfo = New Globalization.CultureInfo(Common.Culture) ' see Common.Culture below Threading.Thread.CurrentThread.CurrentCulture = CultureInfo Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo Response.Redirect(Request.RawUrl) ' load same page again End Subhere is my page init code
Protected Sub Page_Init(ByVal sender As Object, ByVal e As System.EventArgs) Dim CultureInfo = New Globalization.CultureInfo(Common.Culture) Dim UserIdentityId% Threading.Thread.CurrentThread.CurrentCulture = CultureInfo Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo End SubHere is my method to set the culture it is in Common Class, so i call it like Common.Culture
' if no culture is defined it returns english always Public Shared Property Culture$() Set(ByVal value$) HttpContext.Current.Session!Culture = value End Set Get If String.IsNullOrEmpty(HttpContext.Current.Session!Culture) Then Culture = "en-US" Return Culture End If Return HttpContext.Current.Session!Culture End Get End PropertyCheers!
Tarun Juneja
http://meghainfotech.wordpress.com/