ASP.NET page localization problems

J

jmjacquel

Hi all,

I have a localization problem in ASP.NET (ASPX) pages using VS.NET 2003.

I have a project called AGCENTRAL, which is part of a solution. The project
simply contains pages, a MyResources.resx file and a MyResources.frr.resx
file. In these two files, I have a simple string named mystr with "Hello
user" in the MyResources.resx file and mystr with "Bonjour Utilisateur" in
the MyResources.fr.resx file.

I try to access these resources using the following code :

Thread.CurrentThread.CurrentCulture =
CultureInfo.CreateSpecificCulture("fr");
Thread.CurrentThread.CurrentUICulture =
CultureInfo.CreateSpecificCulture("fr");
ResourceManager rm = new ResourceManager("AGCENTRAL.MyResources",
Assembly.GetExecutingAssembly());
thestr=rm.GetString(resid);

When I compile the project, I correctly get the following assemblies :

bin/AGCENTRAL.DLL
bin/fr/AGCENTRAL.resoources.dll

But when the code is running, I always get the default resource value "Hello
user" instead of the correct culture resource value "Bonjour Utilisateur".

I tried to compile the resources files manually using resgen and creating
the satellite assemblies manually too using AL with the same result. I read
many samples or technical notes, doing exactly what was written with always
the same result. I am surely missing something ?!

Any help would be very appreciated !

Best regards,

Jean-Michel JACQUEL
(e-mail address removed)
 
M

Michael Jones

Since you are calling CreateSpecificCulture with the neutral culture of "fr"
it is defaulting to a specific culture of fr-FR (French language in the
country of France). So you can either create a new resource file named
MyResources.fr-FR.resx or if you prefer to stick to the neutral french you
could change your code to:

Thread.CurrentThread.CurrentUICulture=new CultureInfo("fr");

HTH,

Michael Jones
 
Y

Yan-Hong Huang[MSFT]

Hello Jean,

Is the problem resolved now? If there are follow up questions, please post
here. Thanks.

Best regards,
yhhuang
VS.NET, Visual C++
Microsoft

This posting is provided "AS IS" with no warranties, and confers no rights.
Got .Net? http://www.gotdotnet.com
--------------------
!From: "Michael Jones" <[email protected]>
!References: <[email protected]>
!Subject: Re: ASP.NET page localization problems
!Date: Wed, 9 Jul 2003 15:24:22 -0400
!Lines: 59
!X-Priority: 3
!X-MSMail-Priority: Normal
!X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
!X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
!Message-ID: <empD9#[email protected]>
!Newsgroups: microsoft.public.dotnet.framework.aspnet
!NNTP-Posting-Host: 174-33.no1.howardweil.com 216.116.174.33
!Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP10.phx.gbl
!Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.framework.aspnet:158093
!X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
!
!Since you are calling CreateSpecificCulture with the neutral culture of
"fr"
!it is defaulting to a specific culture of fr-FR (French language in the
!country of France). So you can either create a new resource file named
!MyResources.fr-FR.resx or if you prefer to stick to the neutral french you
!could change your code to:
!
!Thread.CurrentThread.CurrentUICulture=new CultureInfo("fr");
!
!HTH,
!
!Michael Jones
!
!!> Hi all,
!>
!> I have a localization problem in ASP.NET (ASPX) pages using VS.NET 2003.
!>
!> I have a project called AGCENTRAL, which is part of a solution. The
!project
!> simply contains pages, a MyResources.resx file and a MyResources.frr.resx
!> file. In these two files, I have a simple string named mystr with "Hello
!> user" in the MyResources.resx file and mystr with "Bonjour Utilisateur"
in
!> the MyResources.fr.resx file.
!>
!> I try to access these resources using the following code :
!>
!> Thread.CurrentThread.CurrentCulture =
!> CultureInfo.CreateSpecificCulture("fr");
!> Thread.CurrentThread.CurrentUICulture =
!> CultureInfo.CreateSpecificCulture("fr");
!> ResourceManager rm = new ResourceManager("AGCENTRAL.MyResources",
!> Assembly.GetExecutingAssembly());
!> thestr=rm.GetString(resid);
!>
!> When I compile the project, I correctly get the following assemblies :
!>
!> bin/AGCENTRAL.DLL
!> bin/fr/AGCENTRAL.resoources.dll
!>
!> But when the code is running, I always get the default resource value
!"Hello
!> user" instead of the correct culture resource value "Bonjour
Utilisateur".
!>
!> I tried to compile the resources files manually using resgen and creating
!> the satellite assemblies manually too using AL with the same result. I
!read
!> many samples or technical notes, doing exactly what was written with
!always
!> the same result. I am surely missing something ?!
!>
!> Any help would be very appreciated !
!>
!> Best regards,
!>
!> Jean-Michel JACQUEL
!> (e-mail address removed)
!
!
!
 
J

jmjacquel

Thank you Michael and Yhhuang for your answers.

Michael, I've already done that without success. I've found the solution by
myself and will explain here what was wrong. In fact, every code I wrote to
solve this problem was correct as I kept each one beside and tried them
again later. As I set impersonation to true, I simply had to set correct
authorizations to the temporary ASP.NET files in the .NET folder. This way,
all my tests are now working correctly.

So, I suppose this thread will help people who are developing multi-lingual
ASP.NET application and using impersonation !

Many thanks again,

Best regards,

Jean-Michel JACQUEL
(e-mail address removed)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top