Re: MFC String-table in C# ?
"Giovanni Dicanio" <giovanniDOTdicanio@REMOVEMEgmail.com> wrote in message
news:O1Gxdt9LJHA.5176@TK2MSFTNGP04.phx.gbl...
It is simpler than the ResourceManager class!
It's simpler because Visual Studio does the resource manager work for you!
I thought I'd add (in case you didn't see it) you can also use localized
resources this way.
Here's an example:
Walkthrough: Localizing Windows Forms
http://msdn.microsoft.com/en-us/library/y99d1cd3(VS.71).aspx
The link shows using a ResourceManager to access the strings, but if you add
a resource file like I described in my last post, the designer generates
that code wrapped in a class.
The resources in that first file become the neutral (not language specific)
resources.
To add culture-specific strings, you can add another resource file with the
same name except with a culture info name (e.g. Resource1.fr-FR.resx).
After adding the same named strings to that resource file, a thread's
CurrentUICulture setting will determine which resource is used:
// Set the current thread's CurrentUICulture
Thread.CurrentThread.CurrentUICulture = new CultureInfo("fr-FR");
// the thread's CurrentUICulture determines where the string is loaded from!
string str = MyResourcesNamespace.Resource1.String1;
I really like how easy the C# dev environment makes this :)
Cheers,
Mark