![]() | |
![]() |
| | Thread Tools | Search this Thread | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
From: spjensen (AT) discussions (DOT) microsoft.com Subject: Localization in Web application Date: Mon, 7 Nov 2005 07:02:02 -0800 Newsgroups: microsoft.public.dotnet.internationalization I have the following resource files in a VB .NET project "RESproj": spjeRes.da.resx spjeRes.de.resx spjeRes.resx The resource project is installed on a Web Server: MESSRV01. I expect the following code to get either the Danish ("da") or the German ("de") localization from this resource project if run on a PC with regional settings set to Danish/Denmark respectively German/Germany and otherwise fall back to the localization in "spjeRes.resx" (which is english) Dim ci As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCultu re Dim rm As System.Resources.ResourceManager Dim assemb As System.Reflection.Assembly Dim s As String assemb = System.Reflection.Assembly.LoadFrom("http://MESSRV01/SmartLoader/OLV/RESproj |
|
rm = New System.Resources.ResourceManager("RESproj.spjeRes" , assemb) Try s = rm.GetString("House", ci) MsgBox(s) Catch ex As Exception MsgBox(ex.Message) End Try This functions well when run on one Client PC but NOT on another. The other Client PC falls back to the localization in "spjeRes.resx" regardless of the regional settings of this client. What possible causes exists for this behavior? -- Regards S. P. Jensen |
#3
| |||
| |||
|
|
First, it appears as though you are attempting to load resources based on the CurrentCulture property (used for data formatting) rather than CurrentUICulture (used for resources). This is the first change I would recommend. Second, you'll probably want to base both the culture and resource selection based on the client computer's browser accept language instead of the user locale setting: ' Setting CurrentCulture to specific culture, based on browser accept language System.Threading.Thread.CurrentThread.CurrentCultu re = System.Globalization.CultureInfo.CreateSpecificCul ture(Request.UserLanguages (0)) ' Setting CurrentUICulture to specific culture, based on browser accept language System.Threading.Thread.CurrentThread.CurrentUICul ture = new System.Globalization.CultureInfo(Request.UserLangu ages(0)) Garrett McGowan [MSFT Developer International] This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm -------------------- From: spjensen (AT) discussions (DOT) microsoft.com Subject: Localization in Web application Date: Mon, 7 Nov 2005 07:02:02 -0800 Newsgroups: microsoft.public.dotnet.internationalization I have the following resource files in a VB .NET project "RESproj": spjeRes.da.resx spjeRes.de.resx spjeRes.resx The resource project is installed on a Web Server: MESSRV01. I expect the following code to get either the Danish ("da") or the German ("de") localization from this resource project if run on a PC with regional settings set to Danish/Denmark respectively German/Germany and otherwise fall back to the localization in "spjeRes.resx" (which is english) Dim ci As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCultu re Dim rm As System.Resources.ResourceManager Dim assemb As System.Reflection.Assembly Dim s As String assemb = System.Reflection.Assembly.LoadFrom("http://MESSRV01/SmartLoader/OLV/RESproj .dll") rm = New System.Resources.ResourceManager("RESproj.spjeRes" , assemb) Try s = rm.GetString("House", ci) MsgBox(s) Catch ex As Exception MsgBox(ex.Message) End Try This functions well when run on one Client PC but NOT on another. The other Client PC falls back to the localization in "spjeRes.resx" regardless of the regional settings of this client. What possible causes exists for this behavior? -- Regards S. P. Jensen |
#4
| |||
| |||
|
|
Thanks for the response I tried your recomandation regarding the use of CurrentUICulture in stead of CurrentCulture. The reaction was the same. But what I really do not understand is why the code piece works on ONE client and NOT on ANOTHER client. I made the conclusion that it had to be incorrect settings of the second client, but what settings influences this behavior? -- Regards S. P. Jensen "Garrett McGowan[MSFT]" skrev: First, it appears as though you are attempting to load resources based on the CurrentCulture property (used for data formatting) rather than CurrentUICulture (used for resources). This is the first change I would recommend. Second, you'll probably want to base both the culture and resource selection based on the client computer's browser accept language instead of the user locale setting: ' Setting CurrentCulture to specific culture, based on browser accept language System.Threading.Thread.CurrentThread.CurrentCultu re = System.Globalization.CultureInfo.CreateSpecificCul ture(Request.UserLanguages (0)) ' Setting CurrentUICulture to specific culture, based on browser accept language System.Threading.Thread.CurrentThread.CurrentUICul ture = new System.Globalization.CultureInfo(Request.UserLangu ages(0)) Garrett McGowan [MSFT Developer International] This posting is provided "AS IS" with no warranties, and confers no rights. Use of included script samples are subject to the terms specified at http://www.microsoft.com/info/cpyright.htm -------------------- From: spjensen (AT) discussions (DOT) microsoft.com Subject: Localization in Web application Date: Mon, 7 Nov 2005 07:02:02 -0800 Newsgroups: microsoft.public.dotnet.internationalization I have the following resource files in a VB .NET project "RESproj": spjeRes.da.resx spjeRes.de.resx spjeRes.resx The resource project is installed on a Web Server: MESSRV01. I expect the following code to get either the Danish ("da") or the German ("de") localization from this resource project if run on a PC with regional settings set to Danish/Denmark respectively German/Germany and otherwise fall back to the localization in "spjeRes.resx" (which is english) Dim ci As System.Globalization.CultureInfo = System.Threading.Thread.CurrentThread.CurrentCultu re Dim rm As System.Resources.ResourceManager Dim assemb As System.Reflection.Assembly Dim s As String assemb = System.Reflection.Assembly.LoadFrom("http://MESSRV01/SmartLoader/OLV/RESproj .dll") rm = New System.Resources.ResourceManager("RESproj.spjeRes" , assemb) Try s = rm.GetString("House", ci) MsgBox(s) Catch ex As Exception MsgBox(ex.Message) End Try This functions well when run on one Client PC but NOT on another. The other Client PC falls back to the localization in "spjeRes.resx" regardless of the regional settings of this client. What possible causes exists for this behavior? -- Regards S. P. Jensen |
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
| |