- Home - Products - Tech Support - Downloads - Order - Contact Us -
Localization Guru Sample Project (Page 3)
The project properties should be set so that "Sub Main" is the startup object for the project. This allows the programmer to determine what language is going to be used and setup Localization Guru prior to the first application Form being displayed.
Click here to take a look at the Main() subroutine used in the sample project. This code sets the path to the language database and the language INI file. The global gLG variable is set to point to the Localization Guru engine. If a default language has been specified in the language INI file then it is used, otherwise the user is allowed to choose the language that will be used. Finally, the main form of the application is shown.
This step is about as simple as it gets. All you need to do is add the following line of code near the end of the Form_Load event for each form that should be localized.
Call gLG.TranslateForm(Me) ' Translate this form.
Any translatable string constants that are defined in the application's code need to be placed in the LocGuruGetS function (as discussed here). Then, wherever these string constants were used a call to gLG.GetS(StringConstantName) needs to be used. Remember, you do not use LocGuruGetS to handle the strings that are stored in the Forms, and the controls on these Forms, of your application. These strings are actually stored in your .FRM and .FRX files and they will be localized when the Form is loaded due to line of code that you added to the Form_Load event in Step 3 for each form you wish to localize. The only string constants that you must handle with LocGuruGetS are those that are defined within the application code.
Here is an example of some code that was used to load text into the ComboBox control on the main form of the sample project prior to using Localization Guru. As you can see, string constants were used to load the ComboBox.
Combo1.AddItem "Easy to use" Combo1.AddItem "Translation is fast" Combo1.AddItem "Multiple languages" Combo1.AddItem "Language Editor included" Combo1.AddItem "Source code" Combo1.AddItem "Online help" Combo1.AddItem "Code examples" Combo1.Text = "Localization Guru Advantages"
Here is the same section of code after the string constants had been moved into the LocGuruGetS function and the gLG.GetS(StringConstantName) function call is used to fetch the string constant. Click here to see the code in the LocGuruGetS function where these string constants are now stored.
Combo1.AddItem gLG.GetS(Feature1_str) Combo1.AddItem gLG.GetS(Feature2_str) Combo1.AddItem gLG.GetS(Feature3_str) Combo1.AddItem gLG.GetS(Feature4_str) Combo1.AddItem gLG.GetS(Feature5_str) Combo1.AddItem gLG.GetS(Feature6_str) Combo1.AddItem gLG.GetS(Feature7_str) Combo1.Text = gLG.GetS(Feature0_str)
The process of moving string constants out of the application code and into the LocGuruGetS function and then fetching them with the gLG.GetS(StringConstantName) function call is similar to the process used with storing strings in a resource file and using the LoadResString function to fetch them.
The last step involves modifying the Localization Guru supplied function ExportAppStrings so that all of the Native language text in your application can be exported to a language database. The main thing that must be done here is to submit each of the forms contained in the application to the gLG.ExportFormStrings function so that the text contained in the form can be exported to the language database. Click here to see the ExportAppStrings function that is used in the sample project.
In the sample project the "Export Strings to a Language Database" functionality was packaged as a menu choice on the main menu. In your project you might want to enable this functionality only when in the VB IDE. Or, you might want to hide it as a easter egg such that when you Ctrl-Alt-Shift and Right-Click in a certain place the ExportAppStrings function is called.
Well, you are finished with the coding changes that must be made to accommodate Localization Guru. You still need a linguist to translate the Native text that was exported from the application into the desired foreign languages. And, you will probably need to adjust the width and placing of controls like Caption and TextBox to compensate for the greater width of the foreign language strings. Remember that Localization Guru can simulate the increased width of foreign language strings as discussed here.
Visual Basic is a registered trademark of Microsoft Corporation.
Copyright © 1998-2005 Beta-Sigma Data Systems LLC