ResourceManager testbed

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

This is my first experience using the ResourceManager to localize UI
elements. I have created a culture neutral .resx, a German (de) .resx, and
an English (en) .resx. My goal is to initially test this to make sure that
it pulls the correct strings based on the local culture. To do this, I
changed my regional options to German, however it still shows the English
version when I run.

Is this a correct testbed for this, or is there something more/different
that needs to be done? It seems like, although I've changed the regional
settings in the control panel, it still senses the culture as English.
 
Hi Chuck,

Could you please add some code of how you retrieve the string.

Regards,

Patrick
 
Patrick,

The initial declaration instances a static resource manager for the class
library as follows:

private static ResourceManager resources = null;

public static ResourceManager Resources
{
get
{
if (resources == null)
{
resources = new ResourceManager("ASNDATA.StringTable",
Assembly.GetExecutingAssembly());
}
return resources;
}
}

When requesting a string from the table, the following code is invoked:

string message;

message = <DLL Namespace (Name changed to protect the
innocent)>.Data.Internal.Resources.GetString("MESSAGE_QUEUE_EMPTY");

Where MESSAGE_QUEUE_EMPTY is a tag in the string table.

Now, I have a default resource, English resource, and German resource, and
for testing purposes, I've made the string in each .resx corresponding to
this tag different. When the string is retrieved, regardless of the regional
settings, the English satellite assembly is loaded and used.
 
Hello, Chuck,

Try writing the following:

System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("de-DE")

Regards.


"Chuck Shuhler" <Chuck (e-mail address removed)> escribió en el mensaje | This is my first experience using the ResourceManager to localize UI
| elements. I have created a culture neutral .resx, a German (de) ..resx, and
| an English (en) .resx. My goal is to initially test this to make sure that
| it pulls the correct strings based on the local culture. To do this, I
| changed my regional options to German, however it still shows the English
| version when I run.
|
| Is this a correct testbed for this, or is there something more/different
| that needs to be done? It seems like, although I've changed the regional
| settings in the control panel, it still senses the culture as English.
 
Hi Chuck,

When calling GetString you should specify the desired culture.
E.g. GetString("MESSAGE_QUEUE_EMPTY", Thread.CurrentThread.CurrentCulture);

Then when changing the regional, your language goes along.

Regards,

Patrick
 
Back
Top