Displaying translated strings
After you translate the strings in a .tra file, you can build an .mpr file for the other language, reconfigure your system for the other language, and then display the translated strings in your application.
Building .mpr files for translated strings
To take the translated strings and add them to an .mpr file, change and evaluate the sample expression in the Building Translated MPR files window, which essentially provides:
AbtNlsTranslatedMprBuilder new
buildNewBinaryMpr: '<new .mpr file>'
fromExistingBinaryMpr: '<original .mpr file>'
fromTraFilename: '<.tra file>'
For AddressApplication, where the German translation file is aaaddg10.tra and you want the new .mpr file to have the name aaaddg10.mpr, you evaluate:
AbtNlsTranslatedMprBuilder new
buildNewBinaryMpr: 'aaaddg10.mpr'
fromExistingBinaryMpr: 'aaadde10.mpr'
fromTraFilename: 'aaaddg10.tra'
To include several .tra files in one .mpr file, use fromMultipleTraFilenames: #(<'first .tra file 'second .tra file'>).
This code is useful for translating different parts of a .tra file at different times. For example, new messages may have been added after your first round of translations. Since the .tra creation process is really an overlay process, you can overlay (that is, translate) parts or all of a given .tra file. If you find it easier to manage your translation tasks by breaking up your .tra files then using this code will allow you to build the new translated .mpr without first manually gluing all of the .tra pieces back together. Here are the ground rules for doing this:
o You must always have the appropriate Begin and End lines.
o You may include any number (1, 5, all) of indexed messages or pool dictionary entries.
o You should always keep a GUI section intact.
Using a different .mpr file
To get VA Smalltalk to use a different .mpr file for your application, ensure that VA Smalltalk can find the file in the path designated in abt.ini, then select NLS > Rebind Image Strings from the Tools menu of the Transcript.
So VA Smalltalk can find the file, the sixth character of the
.mpr file name must correspond with the language setting for VA Smalltalk and for the country setting of your workstation.
Setting language preferences lists the characters that VA Smalltalk uses in the sixth character position to specify language settings. To change the language settings for VA Smalltalk, you might need to add
language=<language> and
territory=<country> to the
abt.ini file in the main VA Smalltalk directory; and then restart VA Smalltalk.
To quickly reconfigure VA Smalltalk so it uses the translated .mpr file, rename the translated .mpr file to the file name your VA Smalltalk system looks for, place the file where VA Smalltalk can find it, and evaluate the expression. By renaming the file, you don't need to change the abt.ini file or your workstation's country settings. For AddressApplication, you might backup the .mpr file that VA Smalltalk recognizes and give the german .mpr file that name. For example, rename aaaddg10.mpr to aaadde10.mpr. Then, select NLS > Rebind Image Strings from the Tools menu.
Displaying the translated text in your application
When you open the view in a VA Smalltalk editor, the strings might still appear in the original language. To see the translated strings, open the view through an openWidget connection, or through a script like the following:
openAddressApplication
AddressView new openWidget
Or, simply Execute the following code in the System Transcript window:
AddressView new openWidget.
Here's what
AddressView looks like in German:
Last modified date: 02/16/2021