LOCALIZING YOUR APPLICATIONS WITH TRANSLATOR -------------------------------------------- 1. What is localization It is a process of translation of your application to other languages. 2. How to localize your C++ Builder 4.0 applications? This is performed in two steps: a. translate all forms b. translate all strings and put them in separate resource files 2.a Translating forms I assume you have a working project from which your application can be built (let's name it PROJ). Now open PROJ with BCB. Select File / New / Resource DLL Wizzard. Add all forms in your project (BCB adds two files by itself. Can be deleted if you're not using databases). Add ALL forms. This is important. BCB will create a new directory named by your selected language and county (for example: ENU means ENglish+United states) and put the copy of all forms in it. Now translate forms with Object inspector. DO NOT: - translate names of objects - change other properties than Caption / Items /... which show on form - EVER open Datamodules. There is a bug which causes your app to hang on startup if you'll do this! The best workaround is that you re-create your project with wizzard and copy all translated forms into this new project. After you do a successfull build you will get a file named PROJ.LLC where LL is selected language (EN=english) and C is country (U=USA). Lets's say you got PROJ.ENU. Now copy this ENU file to your original PROJ directory (where PROJ.EXE is located). You can now try to run your localized application by: - changing your system locale settings (inappropriate) - adding an entry to registry: HKEY_CURRENT_USER/Software/Borland/Locales add a string, named as a full path to your program. It's value shall be "LLC" (in our case "ENU"), for example: key: "C:\Work\MyApps\Proj.exe" value "ENU". Now run (from Explorer) proj.exe. Nice, eh? 2.b Translating strings Here you can use Translator. You shall make a .RC file for every language and one .RH file for a header. Your app than loads in run-time proper string from proper resource file. Let's say your PROJ.RH looks like this: #define S_FILE 1000 #define S_OPEN 1001 //etc. than your ENU\ENGLISH.RC shall be something like: #include "PROJ.RH" STRINGTABLE { S_FILE, "File" S_OPEN, "Open" //etc. } and your MY_LANGUAGE.RC shall be: #include "PROJ.RH" STRINGTABLE { S_FILE, "word_in_my_language_for_file" S_OPEN, "word_in_my_language_for_open" //etc. } Add ENGLISH.RC to your ENU\PROJ project and MY_LANGUAGE to your original PROJ. This assumes you are translating TO english. If it's other way around, just swap the RC files. You can manage .rc files from within BCB, but there is a problem: you will only see ONE RC (one string table at a time)! Unusable. You would like to see them all! Here comes in Translator. 3. Using Translator Run Translator. Press button "Settings". Name your project (PROJ). Now fill in (an example): - project directory: C:\Work\MyApps - header file: proj.rh - resource files: English.rc ENU My_language.rc . ("." means using project directory. Do NOT leave this blank. Use ".") - function: just enter LRS. I'll explain later. - start ID: just enter 1000. I'll explain later. Click 'Save'. Congratulations! You did your first Translator project! Now click 'OK'. If files are found, they're loaded into stringgrid in main form. You shall see something like S_FILE word_in_my_language_for_file File S_OPEN word_in_my_language_for_open Open ... That's it. Add new ID's & new translations as you wish. You can save the work anytime. 4. Using resource strings Your program shall use a function for loading resorce strings from appropriate RC file. This means: Label1->Caption="File"; shall be changed to Label1->Caption=LRS(S_FILE). Function LRS looks something like: ------------------------ String LRS(int id) { ResourceString abc; abc.hinstance = &HInstance; abc.id = id; return System::LoadResourceString(&abc); }; ------------------------ 5. Speeding up process Let's say you start to translate strings. You opened UNIT1.CPP from your PROJ and you came to the line Label1->Caption="File"; CTRL+C "File", switch to Translator and make an entry like S_FILE word_in_my_language_for_file File Now double click first column (S_FILE) in stringgrid. You shall see in Clipboard edit box "LRS(S_FILE)". Switch back to BCB and just CTRL+V this over your "FILE". 6. Problems As a last resort you can allways e-mail me: savingorup@hotmail.com. 7. DEMO Demo project is included. It has one simple form. If you run DEMO.EXE you shall see it in my native language (Slovene). Click the button. You see the label changes in runtime. 1) If you're using English-US locale: just copy DEMO.ENU file from ENU subdirectory to directory where DEMO.EXE is located. Run DEMO.EXE again and you should see everything in english. 2) If you're using other locale: Add registry key: HKEY_CURRENT_USER/Software/Borland/Locales String "full_path_to\DEMO.EXE" value "ENU". Copy DEMO.ENU file from ENU subdirectory to directory where DEMO.EXE is located. Run DEMO.EXE again and you should see everything in english. 8. Full source code of Translator is available on request. Drop a mail to savingorup@hotmail.com. GOOD LUCK.