HighTechTalks DotNet Forums  

resx files and localization

Dotnet Internationalization microsoft.public.dotnet.internationalization


Discuss resx files and localization in the Dotnet Internationalization forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
gabriel
 
Posts: n/a

Default resx files and localization - 01-30-2006 , 01:03 PM






greetings,

I am developping a windows form app and trying my hand at i18n.

private ResourceManager messages ;
public Form1()
{
CultureInfo frenchCulture = new CultureInfo("fr-FR");
Thread.CurrentThread.CurrentCulture = frenchCulture;
this.InitializeComponent();
this.messages = new ResourceManager("galeryMaker.messages" ,
Assembly.GetExecutingAssembly());


//Will correctly extract the ERR_DIR_BUSY msg from
galeryMaker.messages.fr-FR.resx
string test = messages.GetString("ERR_DIR_BUSY", frenchCulture);

// Will fail
string test = messages.GetString("ERR_DIR_BUSY");


....
}


My question is this : why do I have to define the culture I want to use
in the getString method if I have defined it in the
Thread.CurrentThread.CurrentCulture reference ???

Visual studio is 2003.

Many thx !

Reply With Quote
  #2  
Old   
Mihai N.
 
Posts: n/a

Default Re: resx files and localization - 01-31-2006 , 01:21 AM






Quote:
Thread.CurrentThread.CurrentCulture = frenchCulture;
....
//Will correctly extract the ERR_DIR_BUSY msg from
galeryMaker.messages.fr-FR.resx
string test = messages.GetString("ERR_DIR_BUSY", frenchCulture);
// Will fail
string test = messages.GetString("ERR_DIR_BUSY");
You have to set Thread.CurrentThread.CurrentUICulture
Strings is about UICulture, UICulture is about formatting
time/date/numbers/etc.


--
Mihai Nita [Microsoft MVP, Windows - SDK]
http://www.mihai-nita.net
------------------------------------------
Replace _year_ with _ to get the real email


Reply With Quote
  #3  
Old   
gabriel
 
Posts: n/a

Default Re: resx files and localization - 02-02-2006 , 02:48 PM



Mihai N. wrote:
Quote:
Thread.CurrentThread.CurrentCulture = frenchCulture;

...

//Will correctly extract the ERR_DIR_BUSY msg from
galeryMaker.messages.fr-FR.resx
string test = messages.GetString("ERR_DIR_BUSY", frenchCulture);
// Will fail
string test = messages.GetString("ERR_DIR_BUSY");


You have to set Thread.CurrentThread.CurrentUICulture
Strings is about UICulture, UICulture is about formatting
time/date/numbers/etc.


Thank you very much : that was it !!


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.