views:

499

answers:

6

I'm using Visual Studio (2005 and up). I am looking into trying out making an application where the user can change language for all menues, input formats and such. How would I go on doing this, as I suppose that there is some complete feature within .Net that can help me with this?

I need to take the following into account (and fill me in if I miss some obvious stuff)

  • Strings (menues, texts)
  • Input data (parsing floats, dates, etc..)
  • Should be easy to add support for another language
A: 

http://msdn.microsoft.com/en-us/library/y99d1cd3(VS.80).aspx

Loren Segal
The explanation in this page is not the best option. A develper should not have to create language resource files. Also, look for standard language resource files that are compatible with translation memory software if you want to regularly translate your software strings.
Vasco Duarte
+1  A: 

For strings you should just separate your strings from your code (having an XML/DLL that will transform string IDs to real strings is one way to go). However you do need to make sure that you are supporting double byte characters for some languages (this is relevant if you use C/C++).

For input data what you want is to have different locale's. In Java this is relatively easy, and if you use C# it probably is quite easy also. In C/C++ I don't really know. The basic idea is that the input parsers should be different based on the locale selected at that time. So each field (textfield, textbox, etc.) must have an abstract parser that is then implemented by a different class depending on the locale (right to left, double byte, etc.).

Check the Java implementation for details on how they did it. It is quite functional.

Vasco Duarte
+2  A: 

I'm not an expert with .NET by any means but Localization is never just as simple as "swapping out String values" or "changing date formats". There is much more to be taken into consideration such as layout, proper text placement.

Take Chinese for example. The way you read is top to bottom not left to right. If properly localized the app should take that into account.

http://msdn.microsoft.com/en-us/library/y99d1cd3(VS.80).aspx seems to be a good start though if you're dealing with Windows Forms.

Randyaa
Ah, thanks. Links are very helpful.
Statement
+2  A: 

The classic recipe is: design the app with no native language but a localization facility, and develop an initialization into one language (e.g., English). So you build the app and localize it into English every night; without the localization step it would not be usable. Do that well, and the resources for the initial sample localization can be replaced with those for any other language. Take into account non-roman scripts from the beginning. It's much cleaner to have a no-language app that always requires localization rather than a language-specific app that needs to have its native language subtracted and a replacement added.

+1  A: 

You definitely need to be using the .NET ResourceManager and the resx file xml format, however there are a number of approaches to using this.

It really depends on what you are wanting to achieve. For me I wanted a single xml resource file (for each supported language) that could be modified by anyone. I created a helper class that loaded the global resource file into ResourceManager (once only) and I had a helper function that gives me the required resource for a given name. The only disadvantage in this approach was that I could not leverage dynamic binding of resources to properties.

I found this better and easier to manage than multiple or embedded resource files for every form. Additionally exactly the same approach can used in an ASP.NET application. I also found this approach means that outsourcing translation of resources and shipping language packs to customers much more manageable.

Crusty
+1  A: 

Microsoft's recommended approach is to use satellite assemblies, as described in Packaging and Deploying Resources. If you're using a ResourceManager to load resources, .NET will load the correct resources for the CurrentUICulture. This defaults to the user's current UI language setting in Windows.

It is possible to localize Windows Forms either through Visual Studio or an external tool, WinRes.exe. This article describes WinRes and how to use Visual Studio to localize the form.

Mike Dimmick
Very interesting. Will look into these links as soon as I get time off WAR.
Statement