- Internationalization (i18n)
- the process of changing your software so that it isn't hardwired to one language/locale/culture.
- Localization (l10n)
- the process of adding the appropriate resources to your software so that a particular language/locale is supported. It's bigger in scope than just this Wikipedia entry, but it's a good start.
The value of distinguishing between them is that (theoretically) once your program goes through the i18n process, you can then iterate many l10n processes as you need them; also, it's nice to be precise with language.
- Add a Resource file to your project (you can call it "strings.resx") by doing the following:
Right-click Properties in the project, select Add -> New Item... in the context menu, then in the list of Visual C# Items pick "Resources file" and name it
- Add a string resouce in the resx file and give it a good name (example: name it "Hello" with and give it the value "Hello")
- Save the resource file (note: this will be the default resource file, since it does not have a two-letter language code)
- Add references to your program:
Run this code:
It should print "Hello".
Now, add a new resource file, named "strings.fr.resx" (note the "fr" part; this one will contain resources in French). Add a string resource with the same name as in strings.resx, but with the value in French (Name="Hello", Value="Salut"). Now, if you run the following code, it should print Salut:
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("fr-FR");
What happens is that the system will look for a resource for "fr-FR". It will not find one (since we specified "fr" in your file"). It will then fall back to checking for "fr", which it finds (and uses).
The following code, will print "Hello":
Thread.CurrentThread.CurrentUICulture = CultureInfo.GetCultureInfo("en-US");
That is because it does not find any "en-US" resource, and also no "en" resource, so it will fall back to the default, which is the one that we added from the start.
You can create files with more specific resources if needed (for instance strings.fr-FR.resx and strings.fr-CA.resx for French in France and Canada respectively). In each such file you will need to add the resources for those strings that differ from the resource that it would fall back to. So if a text is the same in France and Canada, you can put it in strings.fr.resx, while strings that are different in Canadian french could go into strings.fr-CA.resx.
Starting version 4.5, Qt will support both .po and .xliff;