Localization Nuts and Bolts

I l @ ve RuBoard

It's good practice to build your applications with localization in mind. The most important thing you can do to prepare for this is to not embed any strings in your code that the user will see. For example you would never use:

 MessageBox.Show("Hello World!"); 

because it embeds the "Hello World!" string in the source code. To make this program a good global citizen, you would create a default resource where the string was identified by a value. For example,

 MessageBox.Show((String)resources.GetObject("MyHelloworldResourceString"); 

In this line, the actual text of the message is not placed in the code but retrieved from a resource that has a string identified as "MyHelloWorldResourceString" .

If your default culture is US-English, the string would say "Hello World!" If the application needed to be used in France, a satellite assembly with the French resources would have a string with the same "MyHelloWorldResourceString" ID, except that this string would have the value of "Bonjour Le Monde!"

I l @ ve RuBoard


C# and the .NET Framework. The C++ Perspective
C# and the .NET Framework
ISBN: 067232153X
EAN: 2147483647
Year: 2001
Pages: 204

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net