Adding your own language translations to ReportBuilder.
ReportBuilder 12 introduced the Extensible Language Architecture allowing developers to create and/or add as many custom language translations to ReportBuilder as needed. Below is a quick tutorial on how these features can be utilized.
Language Basics
Language files are stored and loaded as dynamic link libraries (.dll), with file extensions reflecting the language they represent. For instance, the English translation files will have the file extension “.eng”, French “.fra”, and so on. The “.dft” extension represents the default language. This is the language that will be loaded by default when ReportBuilder is used.
There are four language files needed for each language translation.
rbPrint.*
rbIDE.*
rbDADE.*
rbRAP.*
During a standard installation of ReportBuilder you are asked if you would like to add a number of built-in languages to the product. Choosing this option will install the built-in language .dll files into your {WINSYS} directory. This will then allow you to select this language as the Report.LanguageID and use a translated version of ReportBuilder.
Create a new language translation
Using the provided language application, it is now possible to create entirely new language translations from scratch. Below are the steps needed to create a new language and add it to your application. The process in which we will be creating custom language .dll files is as follows.
ReportBuilder Language Application => RC Files => Delphi Resource (.res) files => Language Library (.dll) files
1. Download the ReportBuilder Langauge Application from the following location.
http://digital-metaphors.com/lang/rbLang.zip
2. Unzip the archived files and run the rbStringTranslator.exe program. This application gives you an interface to easily translate the text for each control in ReportBuilder. Follow the tips at the top of the form for instructions on creating a new language or editing an existing one.
Create a new Language
—————————–
– Right click over the main window and select “Add New Language”.
– In the dialog, enter the language description and file extension to be used and select OK. (for example… Description: “Polish (Poland)”, Extension: “pol”)
– Move through the list on the left and translate each string. There are four lists which can be selected with the tabs near the top.
3. Once this is finished, right click and select to create RC files. Note that for Unicode versions of Delphi (2009+) the Unicode RC file option will need to be selected rather than ANSI. This will create four .rc files in the application path.
rbPrint.rc
rbIDE.rc
rbDADE.rc
rbRAP.rc
4. Use the resource compiler to create .res files from the newly generated .rc files. From the command prompt, use the following commands.
{$DELPHI} represents your main Delphi path.
-ANSI Delphi Versions
{$DELPHI}\bin\brc32.exe -r rbPrint.rc
{$DELPHI}\bin\brc32.exe -r rbIDE.rc
{$DELPHI}\bin\brc32.exe -r rbDADE.rc
{$DELPHI}\bin\brc32.exe -r rbRAP.rc
-Unicode Delphi Versions
{$DELPHI}\bin\rc.exe rbPrint.rc
{$DELPHI}\bin\rc.exe rbIDE.rc
{$DELPHI}\bin\rc.exe rbDADE.rc
{$DELPHI}\bin\rc.exe rbRAP.rc
5. Create new Delphi project files for each of the .res files generated. This can be done in Delphi or in a simple text editor (Notepad). Each file should have the following content structure and be named the same with a .dpr extension. Feel free to copy/paste the code below changing the appropriate sections to match the file/extension being used.
///-------------Language Project File---------------------///
library rbPrint;
{$R rbPrint.res} //Name of the res file to be compiled
{$E pol} //Extension to be given to the .dll file.
begin
end.
///------------------------------------------------------///
Once this is finished there should be four new .dpr files created.
rbPrint.dpr
rbIDE.dpr
rbDADE.dpr
rbRAP.dpr
6. Use the Delphi compiler to create .dll files from the newly generated .res and .dpr files. From the command prompt, use the following commands.
{$DELPHI} represents your main Delphi path.
{$DELPHI}\bin\dcc32 rbPrint.dpr
{$DELPHI}\bin\dcc32 rbIDE.dpr
{$DELPHI}\bin\dcc32 rbDADE.dpr
{$DELPHI}\bin\dcc32 rbRAP.dpr
7. There should now be four .dll files in the directory with the extension given (using the example above, the extension would be “.pol”). These files must now be copied to the application directory or the WINSYS directory to be used.
8. Finally in order to use the langage with ReportBuilder it needs to be registered with the application. This should be done before the report is printed or the designer is shown.
– Add the “ppLangauge” unit to your uses clause.
– Call the ppRegisterLanguage routine to register your new language.
ppRegisterLanguage('Polish (Poland)', 'pol');
Now when the application is executed, the new langauge will be visible when selecting the Report.LanguageID property and the LanguageID property can be assigned to the new language in Delphi code as well.
Report.LanguageID := 'Polish (Poland)';
Report.Print;