views:

371

answers:

5

Hi,

The application I'm writing is almost complete and I'd like people who speak different languages to use it.

I'm not sure where to start, what's the difference between globalisation and culture in regards to programming?

How does one take uncommon phrases such as "this application was built to do this and that" instead of File, Open, Save etc...and turn them into say, Spanish?

Many thanks :-)

+4  A: 

Microsoft already has a very good tutorial

Nescio
A: 

For a very simple system, create an interface which defines methods like GetSaveText(), etc. and allow assemblies like this to be plugged in to your application.

J D OConal
A: 

This should be a pretty good solution for anywhere from 10-1000 strings:

Have a resource file for each locale. I don't know .NET but I'm sure there is some common way to do this. Then, in your resource-fetching code, load the appropriate one based on your user's the browser locale setting. Ask this code to fetch you the proper string for some key.

Example file contents, if I were to implement it from scratch:

resources.en:

save=Save
close=Close
ok=OK
areYouSure=Are you sure?

resources.es:

save=I don't know how to say anything in Spanish, oops
close=...
ok=...
areYouSure=...
Kevin Conner
+2  A: 
Gishu
+2  A: 

You have differents things to do to have a "globalized" application.

1) Translate every label in your forms and controls in your application

You need to set the property "Localizable" to true on every form and control. This property enables the creation of resources files in each language and region. Now, with the property "Language", you can select which language you want to support. When you select a language in the combo box list, your form (or control) will be automatically switched to this language. Now, it is your job to translate every word in the control. As soon as you do a modification, Visual Studio will create a resource file for the specific language. (Per example, MyForm.fr-FR.resx for French-France).

2) Import every hardcoded string in your code into a resx file

Create a resource file (personnally, I use StringTable.resx) and add every string to translate in this file. After that, create a resource file for every language that you want to support and translate the strings in each file. Per example, if you want to support French, you create StringTable.fr.resx or StringTable.fr-FR.resx for French-France. With ResourceManager class, you can load each string.

Note: If you are using Visual Studio 2005 or 2008, you already have a resource files created by default.

3) You need to elaborate your forms and controls wisely

Guidelines from Microsoft: Microsoft Guidelines

4) Dealing with Date and Numbers

If your application creates data files which can be send to other user in other region, you need to think about it when you save your data in the file. So, always stock your datetime in UTC and do the conversion in local only when you load the information. The same thing applies to decimal number especially if they are stored in text.


When you will compile your application, Visual Studion will create satellite file like MyApplication.fr.dll in a subfolder fr. To load this dll, you need to switch the language of the current thread at the startup of your application.

Here the code:

CultureInfo ci = new CultureInfo("fr");
Thread.CurrentThread.CurrentUICulture = ci;
Francis B.