[Home] [Puzzles & Projects] [Delphi Techniques] [Math Topics] [Library] [Utilities]
A "Hello World" program to examine techniques and pitfalls in "Internationaliziing" a program to support foreign languages.
Background & Techniques
A while ago I had the chance to convert a program to support an Italian non-profit organization intending to use my Reaction Times program with non English-speaking young people. There are some good, free, tools but it took a few days of study to pick up on how to use them for even the simplest case with a single language. l decided to write a "do-nothing" program so I could concentrate on how to generalize it to handle multiple languages.
The free tools I used are dxGetText, a translation toolkit for Delphi and PoEdit, which helps enter translations for strings extracted from your program by dxGetText. Both programs are also available from SourceForge.net.
I'll outline the program first and then provide some notes about the use of the above tools used to implement it. The program displays one of two messages: "Hello World!" or "Goodbye!" toggled by a "Change message" button. A radio group allows choice of several languages (currently English, French, German, Spanish, and "Southern USA" just for fun). The messages and all of the displayed text (titles, labels, and radio group contents) are displayed in the chosen language. The language choices in the radio group are built dynamically, so additional languages could be added simply by adding translation sets (.po and .mo files) for other languages in the defined location ("locale/xx/Lc_messages" folder within the folder containing the source code and recompiling the program. "xx" in the previous folder structure is the two letter id code for the language ( "fr", "de", and "es" for the initial set). These language id's and the languages names are defined in ISO Standard 639.1.
I have not tested the program with a "locale" language other than English. In fact, I'm not even sure how to do that. It should recognize and honor the other three languages but I'm sure someone will let me know the symptoms when it doesn't work!
Here are some notes about elements of multi-language support as implemented here:
One more note, the dxGettext manual has sample code which retrieves the two letter codes for the target languages included with a program, but I could not find a clean way to convert the two letter ISO639.1 codes to language names, so i made one. File ISO639V1.txt included in the downloads has the 200 or so codes and names defined by the standard. I load that file into a string list, LanguageTable, and use it to display the names of the languages found.
Suggestions for Further Explorations
Copyright © 2000-2013, Gary Darby
All rights reserved.