See also: INTL FAQ and How to purchase INTL.
Here are some of the tasks that INTL can manage for you. This also gives you an idea about how INTL works.
Instancing INTL
Localizing forms
Automatic form localizaton
Localizing menus
Changing languages
Changing languages on the fly
Configuring INTL objects
Configuring INTLs strategies
Updating resource files automatically
Localizing reports
Localizing strings
Localizing fonts
Localizing data sources
Localizing images
Localizing currencies
Localizing for right-to-left writing
systems
Customizing strategies
Ignoring a particular object
How to work with locales
File placement
Distributing INTL files
The important thing is for VFP to find INTLs files as needed. Heres where to put your INTL files so they are available to your development environment:
| File | Location |
|---|---|
| GENMENUX.PRG | VFP root or the project root directory. |
| INTL.PRG | VFP root or the project root directory, or along SET PATH. |
| STRINGS.DBF STRINGS.FPT STRINGS.CDX |
Project root directory, or along SET PATH. |
| MSGSVC.DBF MSGSVC.FPT MSGSVC.CDX |
VFP project root directory, or along SET PATH. |
In order to use INTL, your application must instantiate an INTL object. There are many ways to do this, the best being to add it to _SCREEN, like this:
Place a call to oINTL in your Form.Init() hierarchy. To make your forms localize themselves automatically call the oINTL.Localize() method in your form class hierarchy. To do so, place the following code in the INIT() method of your form class definition.
A GENMENUX driver is used to localize menus. To activate GENMENUX and its INTL.PRG driver, put the following lines in your CONFIG.FPW:
Some of these changes require a VFP restart.
This change will take effect the next time you start Visual FoxPro. To avoid restarting FoxPro at this time, issue the following command in the command window:
This is all you need to change in your development environment to localize menus. Henceforth generate menus as usual.
Note: GENMENUX does not replace Visual FoxPros native menu generator. Since GENMENUX calls GENMENU.PRG, your code is generated by Visual FoxPro as usual. The INTL Toolkit uses GENMENUX as a pre-processor. GENMENUX is a rich program. Please see the GENMENUX section in the Appendix.
The structure of STRINGS.DBF determines which languages you support. Use the SetLanguage() method to change INTLs language.
INTL comes with a table named STRINGS.DBF which contains a variety of fields, one of which is cOriginal, and it may contain other fields for different languages, for example cFrench, cGerman, cSpanish, and so on.
The languages you support is determined by the structure of the STRINGS.DBF table. To add a new language, just change the structure of STRINGS.DBF.
To change the current localization language, use the SetLanguage() method. Say we want a form to be in French. First set the language, then we localize the form:
Nothing demos better than swapping the display language on the fly. To swap languages on the fly, which is always a success in a demo (do it even if it isn't required it's so easy), create a mechanism in your application to configure the INTL object with SetLanguage(), as follows.
To change your application's locale-based personality, I suggest you subclass INTL to work as you need. Here is an example of an INTL subclass that works for me in a variety of locales.
In this example, I've subclassed the INTL class to change all the locale-specific settings at one go. Subclassing INTL for your own needs is a great way to meet locale demands with a minimum of code and fuss.
I recommend making a main INTL object named _SCREEN.oINTL. It's possible to have several separate INTL objects co-exist together. Each INTL object is itself an amalgam of other INTL objects called hooks or strategies. Your main INTL object is the master INTL object in your environment, and whichever it happens to be, I assume here that it's called _SCREEN.oINTL .
Use the SetConfig( n) method to configure your main INTL object. You configure INTL with a _SCREEN.oINTL.SetConfig( n) method, where n is a bitwise integer value with the following interpretation:
| Value | Configuration Meaning |
|---|---|
1 2 4 8 16 32 |
Load the String strategy Load the Font strategy Load the Data strategy Load the Picture strategy Load the Currency strategy Load the Right-To-Left display strategy |
Configuration integers for the ::SetConfig() method for the various INTL classes.
Example: create an INTL object that localizes strings and fonts
The operative language and locale of the main INTL object are configured with the SetLanguage() and SetLocale() methods.
Strategies are bitwise configured. Configuring individual strategies is easy. Simply get a reference to the strategy, then configure it. Here are the configuration meanings for each configurable strategy.
| Strategy | Value | Localization |
|---|---|---|
| Data | 1 (Default) 2 4 8 16 |
BoundColumn ControlSource RowSource RecordSource InputMask |
| Font | 1 (Default) 2 (Default) |
Font and FontSize DynamicFont and
|
| Picture | 1 (Default) 2 4 (Default) 8 |
Picture DownPicture Icon DragIcon |
| Right to Left | 1 | All display objects are mirrored within their container. |
| Strings | 1 (Default) 2 (Default) 4 (Default) |
Caption ToolTipText StatusBarText |
Configuration integers for the ::SetConfig() method for the various INTL classes.
To get a handle on a loaded strategy, use the ::GetStrategy() method. Thereafter, use the handle's SetConfig() method to configure the strategy.
Example: create an INTL object that localizes strings but not Tooltips. Use the oINTL.GetStrategy() method to get an object reference, then use its SetConfig() method to configure it.
Example: create an INTL object that localizes only strings and InputMasks.
Interface strings are usually the first things that come to mind when we think of translating software. This table lists the configuration bits for INTL. These configuration bits decide which strategy is loaded. By default, only the String strategy is loaded, which is to say that strings are automatically localized by INTL by default.
| Class | Configuration bits | Localization |
|---|---|---|
|
INTL |
1 (Default) 2 4 8 16 32 |
String strategy loaded Font strategy loaded Data strategy loaded Picture strategy loaded Currency strategy loaded Right-to-Left loaded |
|
String Strategy |
1 (Default) 2 (Default) 3 (Default) |
Caption ToolTipText StatusBarText |
So activate the string strategy as follows:
Another more cryptic way to load the String strategy is:
So there are two ways to do it.
Strings can be localized by providing translations in STRINGS.DBF.
| cOriginal | cFrench |
|---|---|
| Yes | Oui |
| No | Non |
Configure the String Strategy with its SetConfig() method. The INTL String strategy, like all strategies, is bitwise-configured. You can control the string strategy object as follows:
Example: to disable font processing for the ToolTipText property:
Fonts can be locale-specific. Fonts like Arial, Times New Roman, MS Sans Serif might not be suitable in some languages. This matters; we may need a way to change fonts when we change locales.
The following table lists the configuration bits for the INTL object to load the Font strategy, and the configuration integers to configure the Font strategy:
| Class | Configuration bits | Localization |
|---|---|---|
| INTL |
1 (Default) 2 4 8 16 32 |
String strategy loaded
Font strategy loaded Data strategy loaded Picture strategy loaded Currency strategy loaded Right-to-Left loaded |
| Font Strategy |
1 (Default) 2 (Default) |
Font and FontSize DynamicFont and DynamicFontSize |
So activate the font strategy as follows:
Another more cryptic way to load the Font strategy is:
So there are two ways to do it.
Fonts can be localized by providing translations in STRINGS.DBF. Font specifications are prefixed with the identifier "((Font))", like for example:
| cOriginal | cRussian |
|---|---|
| ((Font))Courier New,10 | ((Font))Courier New Cyr,10 |
| ((Font))Arial,16 | ((Font))Arial Cyr,16 |
Configure the Font Strategy with its SetConfig() method. The INTL Font strategy, like all strategies, is bitwise-configured. You can control the font strategy object as follows:
Example: to disable font processing for DynamicFont and DynamicFontSize, which will slightly improve the font strategy performance:
Data can be locale-specific. Sometimes it is the data itself that needs to be localized. INTL allows you to present different fields for different locales. The Data strategy works just like the other strategies. The following table lists the configuration bits for the INTL object to load the Picture strategy, and the configuration integers to configure the Picture strategy.
| Class | Configuration bits | Localization |
|---|---|---|
| INTL |
1 (Default) 2 4 8 16 32 |
String strategy loaded Font strategy loaded Data strategy loaded Picture strategy loaded Currency strategy loaded Right-to-Left loaded |
| Data Strategy |
1 (Default) 2 4 8 16 |
BoundColumn ControlSource RowSource RecordSource InpuMask |
So activate the data strategy as follows:
Another more cryptic way to load the Data strategy is:
So there are two ways to do it.
Data elements can be localized by providing translations in STRINGS.DBF. Data specifications are prefixed with the identifier "((Data))", like for example:
| COriginal | Crussian |
| ((Data))cEngDesc | ((Data))cRussianDesc |
Configure the Data Strategy with its SetConfig() method. The INTL data strategy, like all strategies, is bitwise-configured. You can control the picture strategy object as follows:
Example: Localize ControlSource properties.
Images can be locale-specific. Some of the icons and images we use every day may not be appropriate in other locales. INTL provides a way to change the displayed images when we change locales. The Picture strategy works just like the other strategies. The following table lists the configuration bits for the INTL object to load the Picture strategy, and the configuration integers to configure the Picture strategy.
| Class | Configuration bits | Localization |
|---|---|---|
| INTL |
1 (Default) 2 4 8 16 |
String strategy loaded Font strategy loaded Data strategy loaded Picture strategy loaded Currency strategy loaded |
| Picture |
1 (Default)
2 4 (Default) 8 |
Picture
DownPicture Icon DragIcon |
So activate the picture strategy as follows:
Another more cryptic way to load the Picture strategy is:
So there are two ways to do it.
Pictures can be localized by providing translations in STRINGS.DBF. Picture specifications are prefixed with the identifier "((Picture))", like for example:
| Coriginal | Crussian |
|---|---|
| ((Picture))Doctor.BMP | ((Picture))Doktor.BMP |
| ((Picture))Friend.BMP | ((Picture))Comrade.BMP |
Configure the Picture Strategy with its SetConfig() method. The INTL picture strategy, like all strategies, is bitwise-configured. You can control the picture strategy object as follows:
Example: Localize Picture, DownPicture, and Icon properties.
INTL enables you to endow your application with a simple multi-currency capability. This architecture is flexible, and by subclassing the cINTLCurrency class you can probably implement almost any multi-currency scheme you need. At the heart of it all, the INTL Currency strategy works only on fields having a format property of "$".
Recall that INTL strategies are bitwise-configured according to the following table.
| Class (with default) | Value | Localization |
|---|---|---|
| INTL (1) |
1 2 4 8 16 32 |
String strategy loaded Font strategy loaded Data strategy loaded Picture strategy loaded Currency strategy loaded Right-To-Left loaded |
So activate the currency strategy as follows:
Use oINTL.SetConfig() or oINTL.SetStrategy() to load the Currency strategy.
An alternate (and more cryptic) way is to use INTL's SetConfig() method to make INTL invoke the currencystrategy as follows:
So there are two ways to do it.
The Curremcy strategy is not like the others. The INTL toolkit currency strategy is a little different from other strategies in three important respects:
The default exchange rate for all currencies is 1.00
With the cINTLCurrency class that ships with INTL, you assign currency conversion factors to different currencies. By default the conversion factor used by the Currency strategy is 1.00.
If you need time-dependent currency conversions, you can subclass class cINTLCurrency to do anything you need it to do, such as lookups.
Let's configure INTL for the following currencies: Canadian dollar, German Mark, and US dollar. Assume that our data is based in Canadian dollars.
oINTL.SetConversion() sets the exchange rate between the original and other locales.
Use SetLocale() to change the currency locale.
Localize as usual.
Most of the world does not read from left to right. Both the Oriental and Mid-Eastern writing systems read from right to left. INTL allows you to create applications whose interfaces can display from right to left.
Recall that INTL strategies are bitwise-configured according to the following table.
| Class (with default) | Value | Localization |
| INTL (1) |
1 2 4 8 16 32 |
String strategy loaded Font strategy loaded Data strategy loaded Picture strategy loaded Currency strategy loaded Right-To-Left loaded |
So activate the right-to-left strategy as follows:
Use oINTL.SetConfig() or oINTL.SetStrategy() to load the right-to-left strategy.
An alternate (and more cryptic) way is to use INTL's SetConfig() method to make INTL invoke the right-to-left strategy as follows:
So there are two ways to do it. When the right-to-left strategy is loaded, all your UI elements will be repositioned relative to their UI containers. The object captions will read right-to-left if their rightToLeft properties are true, and if you are using a Middle-Eastern or Oriental version of Windows.
Just like you can subclass an existing strategy, you can create your own strategy and use INTL to automatically invoke it. Just make your new strategy a subclass of the cINTLStrategy class (so you'll have the properties and methods INTL expects) and then run with it!
Just as in the case of subclassing an existing strategy, use the SetStrategy() method to load your strategy into INTL.
Three ways:
INTL ships with iterator and visitor classes designed to recur VFP structures and, among other things, load all the string interface elements into the STRINGS.DBF.
The transformation process turns your report labels into report expressions containing a call to INTL's I() function. For example the report label "Name:" becomes expression I("Name:").
For run time localization, you need to distribute the following files:
| File | Notes |
|---|---|
| I.PRG | For best performance, place this function in your first SET PROCEDURE file. |
| INTL.PRG | For best performance, SET PROCEDURE TO INTL Additive. |
| MSGSVC.DBF MSGSVC.FPT. MSGSVC.CDX |
If you use MsgSvc() you will need to distribute these files. |
| MSGSVC.PRG | The message services library. |
| NOHOT.PRG | For best performance, place this function in your first SET PROCEDURE file. |
| STRINGS.DBF STRINGS.FPT STRINGS.CDX |
Youll need to distribute these too. |
For the STRINGS and MSGSVC tables and files, if you include them in your APP or EXE then they will, of course, be read-only.