Saturday, January 29, 2005
No excuses for not localizing.
More than once, I have created an application for a customer who was certain that it would only be used by their U.S. employees and in English (us-EN) just to have to come back later and add globalization and localization features as employees begin to use the applications worldwide.As a result, I develop any new applications, even if they are only going to be used on my desktop, with as much thought for globalization and localization as possible. Microsoft has made it so simple now that there's just no excuse for not localizing. And even if you (think you) are sure that your application will never be used in another culture, the skills and experience can only help you when you are looking for your next job. Unless there are specific overriding reasons to the contrary, localizable resources, including images, sounds, and strings, should be in resource files.
If you haven't used the globalization and localization features of the .Net framework, spend a few evenings reading and following links from MSDN - The Globalization and Localization Namespaces in Visual Studio.
You have probably seen the Properties folder in your VS2005 projects, and within that folder the Resources.resx file. Have you wondered what is their purpose? It's there for just what you'd expect: localization. The thing that may throw you off is the associated .cs file. That is a class file created by the ResGen utility with VS2005. Now you can have strongly-typed resources and access your resources using Intellisense from within the Visual Studio environment by using the /str command line switch with ResGen. Strongly-typed resources makes coding easier and cleaner.

For more information, see Alan Dean's blog titled "[VS2005] Beta Fun - Chapter 6: Assembly Properties".
The one thing I want to add is how to leverage the Properties/Resources.resx in providing resources for other languages and cultures. It initially appears that you can't, from within the VS2005 environment, add new resource files to the Properties folder. It appears at first that you have to manually create and consume a ResourceManager or ResourceSet to get localized strings if you had more cultures than just the default. After many hours of searching Microsoft's website, MSDN, and the web without even a hint of an answer, I finally stumbled on the solution:
It is as simple as creating the localized resource files outside of the Properties folder and then, from the project explorer, drag the new .resx file into the Properties folder.
For instance, the Properties folder initially has Resources.resx in it. I copied that Resource.resx file to the project folder. There, I renamed it to Resources.en-US.resx and changed the contents enough that I could identify which resource file they came from. I then dragged the new file, Resources.en-US.resx, back to the Properties folder. I could have done the same for any other cultures I wished to support in my application.
That was all there was to it. Now I can use my strings with Intellisense and it works for all supported cultures.
Comments:
<< Home
At Last!!!
Thanks Dale, I have spent ages trying to work out how to utilise the new resource features in VS2005 with languages other then American. I can not believe that there is NO mention of how you add a foreign language resource file in any of the Microsoft documentation. Like you I have added localized resources in all my projects since .NET began (and before in those old .ASP days), I even wrote the Resource Application Block for the .NET v1.1 Enterprise Library to add localized resources after one of the developers freely admitted that they did not really care about any other languages because English is so widely spoken!!! Shame he had not realised that Cantonese (or is it Mandorin?) is the most common language in the world!
Still, thanks for your perseverance you have saved me hours no doubt.
Post a Comment
Thanks Dale, I have spent ages trying to work out how to utilise the new resource features in VS2005 with languages other then American. I can not believe that there is NO mention of how you add a foreign language resource file in any of the Microsoft documentation. Like you I have added localized resources in all my projects since .NET began (and before in those old .ASP days), I even wrote the Resource Application Block for the .NET v1.1 Enterprise Library to add localized resources after one of the developers freely admitted that they did not really care about any other languages because English is so widely spoken!!! Shame he had not realised that Cantonese (or is it Mandorin?) is the most common language in the world!
Still, thanks for your perseverance you have saved me hours no doubt.
<< Home


