intl

2025-12-10 0 909

Steven Black\’s INTL Toolkit for Visual FoxPro

INTL makes short work of creating multilingual software in Visual FoxPro (VFP).
It gives you the ability to create multilingual Visual FoxPro applications while minimizing the hassles of creating multi-version software.

This document serves to describe the following:

  • The INTL Toolkit for Visual FoxPro,
  • GENMENUX,
  • non-linguistic and strategic issues in international development with VFP,
  • VFP’s international features, and
  • other issues germane to spanning locales with your VFP applications.

Table of Contents

  • Installing INTL
  • INTL: How to…
    • How to Correctly Place Your INTL Files
    • How to Instantiate an INTL Object
    • How to Localize Forms
    • How to Get Automatic Form Localization
    • How to Localize Menus
    • How to Change the Current Language
    • How to Swap Languages on the Fly
    • How to Work With Locales
    • How to Demo your App in Swahili Today
    • How to Configure Your Main INTL Object
    • How to Configure Strategies
    • How to Localize Strings
    • How to Localize Fonts
    • How to Localize Data Sources
    • How to Localize Pictures
    • How to Localize Currencies
    • How to Localize for Right-To-Left Writing Systems
    • How to Subclass an Existing Strategy
    • How to Create Your Own Generic Strategy
    • How to Make INTL Ignore an Object
    • How to Make INTL Treat an Object Differently
    • How to Substitute Your Own Strategies
    • How to Batch-Update strings.dbf
    • How to Localize Reports
    • Details of How INTL Works
    • Details of How MsgSvc() Works
    • How to Distribute INTL Files
    • Toolkit File Descriptions
    • Overview of the INTL Class Library
    • Class INTL
    • Class cINTLAbstract
    • Class cINTLCurrency
    • Class cINTLData
    • Class cINTLFont
    • Class cINTLMemento
    • Class cINTLPicture
    • Class cINTLRightToLeft
    • Class cINTLStrategy
    • Class cINTLString
  • Localizing VFP Menus
    • Using GENMENUX to Invoke INTL
    • INTL config.fpw Menu Statements
    • INTL Menu Memory Variables
    • Two Very Useful GENMENUX Comment Directives
  • Message Services
    • Introduction
    • Up And Running
    • MsgSvc() Dialog Return Values
    • Fields in MsgSvc.DBF
    • MsgSvc() Examples
    • Localizing Smart
  • INTLTool
    • Iterators And Visitors
    • Updating strings.dbf Based on a .PJX
    • Updating strings.dbf Based on a .SCX
    • Updating strings.dbf Based on a .VCX
    • Updating strings.dbf Based on a .MNX
    • Updating strings.dbf Based on a .FRX
    • Transforming Reports Based on a .PJX
    • Transforming Reports Based on a .FRX
    • INTL Iterator Classes
    • Class INTLVisitor
  • Extend INTL
    • Creating and Using Hooks
  • VFP\’s International Features
    • Introduction
    • A Survey of VFP\’s International Features
  • International Issues
    • Background
    • Localization Factors to Consider
    • Sources of Cultural Difference
    • Choosing Enabling Strategies
    • Checklist for International Issues
  • Using GENMENUX
    • Introduction
    • GENMENUX Directives
    • Timing of GENMENUX Drivers and Directives
    • Checklist for GENMENUX
    • The MNX Structure
  • Glossary of Terms
  • Acknowledgments

Installing INTL

First, put the INTL files into a clean new directory.

Then,

  • Deploy files: Manually place files relative to your project as described in How to Correctly Place Your INTL Files.

  • Modify the config.fpw file: For menus, add the two lines to the config.fpw file as explained in How to Localize Menus.

  • Seed your Form class definition: For now, probably forever, invoke INTL in forms with a Form::Init() statement that calls the INTL object. See How to Get Automatic Form Localization.

  • If you need localization, instantiate an INTL object: Now when localization is required, create and configure an INTL object as described in How to Instantiate an INTL Object.

INTL: How to…

How to Correctly Place Your INTL Files

It is important for VFP to find INTL’s files as needed. Here’s where to put your INTL files so they are available to your development environment:

Deploy your files as follows:

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.

How to Instantiate an INTL Object

Create a member named _SCREEN.oINTL to hold the INTL instance.

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:

*-- Anywhere, anytime:
*-- Instantiate INTL in _SCREEN
SET PROCEDURE TO INTL ADDITIVE
SCREEN.AddObject( \"oINTL\", \"INTL\" )

How to Localize Forms

Localize forms by passing their object references to the Localize()
method of an INTL object.

Forms (and any other container ) are localized by passing its reference to the oINTL.Localize() method.

*-- Configure oINTL to another language
_SCREEN.oINTL.SetLanguage( \"French\" )

*-- Instantiate a form. If the form calls INTL in its Init()
*-- method, then the form appears in French....
DO FORM MyForm Name MyForm

….or you can localize the form on the fly.

_SCREEN.oINTL.Localize( MyForm )

How to Get Automatic Form Localization

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. |

*-- Don\'t forget to call the ParentClass!
DODEFAULT()

IF TYPE(\"_SCREEN.oINTL\" ) == \"O\"
  _SCREEN.oINTL.Localize( This )
ENDIF

How to Localize Menus

A GENMENUX driver is used to localize menus. To activate GENMENUX and its INTL.PRG driver, put the following lines in your config.fpw:

Add these lines to config.fpw.

*-- Configuring for INTL menus.
_GENMENU = GENMENUX.PRG
_MNXDRV2 = INTL.PRG
*-- End of configuration for INTL menus.

Some of these changes require a VFP restart. To avoid restarting FoxPro at this time, issue the following command in the command window:

_GENMENU = HOME()+”GENMENUX.PRG”

This is all you need to change in your development environment to
localize menus. Henceforth, generate menus as usual.

GENMENUX is very cool. Check it out.

Note: GENMENUX does not replace VFP’s native menu generator. Since GENMENUX calls GENMENU.PRG, your code is generated by VFP as usual. The INTL Toolkit uses GENMENUX as a pre-processor. GENMENUX is a rich program. Please see GENMENUX for more information about its capabilities.

How to Change the Current Language

The structure of strings.dbf determines which languages you support.

Use the SetLanguage() method to change INTL’s 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 are determined by the structure of the strings.dbf table. To add a new language 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 localize the form:

_SCREEN.oINTL.SetLanguage( \"French\" )
_SCREEN.oINTL.Localize( _SCREEN.ActiveForm )

How to Swap Languages on the Fly

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 INTL.SetLanguage(), as follows.

_SCREEN.oINTL.SetLanguage(\"German\" ) && Configure INTL for German

FOR i = 1 TO ALEN(_SCREEN.Forms ) && Localize active forms
  _SCREEN.oINTL.Localize( _SCREEN.Forms[i] )
ENDFOR

DO MAIN.MPR && Refresh the menu too!

How to Work With Locales

To change your application\’s locale-based personality, I suggest you
subclass INTL to work as needed. Subclassing INTL for your own needs is a great
way to meet locale demands with a minimum of code and fuss.

Here is an example of an INTL subclass that works for me in a variety of locales.
We subclass the INTL class to change all the locale-specific settings at once.

Take note of the RightToLeft strategy (class cINTLRightToLeft), which is useful for Middle-Eastern writing systems.

DEFINE CLASS MyINTL AS INTL
  FUNCTION SetLocale( tcLocale )
    IF EMPTY( tcLocale )
      tcLocale = this.GetLocale()
    ENDIF
    IF INTL::SetLocale( @tcLocale )
      DO CASE
      CASE PROPER(tcLocale )= \"Usa\"
        SET CURRENCY TO \"$\"
        SET CURRENCY LEFT
        SET POINT TO \".\"
        SET SEPARATOR TO \",\"
        SET DATE TO American
        SET MARK TO \"/\"
        this.SetRightToLeft( .F. )
        this.SetConversion( \"Usa\", 1.33 )
        this.SetLanguage( \"USEnglish\" )

      CASE PROPER(tcLocale )= \"France\"
        SET CURRENCY TO \" F\"
        SET CURRENCY RIGHT
        SET POINT TO \",\"
        SET SEPARATOR TO \".\"
        SET DATE TO DMY
        SET MARK TO \"/\"
        this.SetRightToLeft( .F. )
        this.SetConversion( \"France\", 0.28 )
        this.SetLanguage( \"French\" )

      CASE PROPER(tcLocale )= \"Germany\"
        SET CURRENCY TO \" DM\"
        SET CURRENCY RIGHT
        SET POINT TO \",\"
        SET SEPARATOR TO \".\"
        SET DATE TO DMY
        SET MARK TO \"/\"
        this.SetRightToLeft( .F. )
        this.SetConversion( \"Germany\", 0.28 )
        this.SetLanguage( \"German\" )

      CASE PROPER(tcLocale )= \"Israel\"
        SET CURRENCY TO \"ILS\"
        SET CURRENCY LEFT
        SET POINT TO \".\"
        SET SEPARATOR TO \",\"
        SET DATE TO British
        SET MARK TO \"/\"
        this.SetConversion( \"Israel\", 0.41 )
        this.SetRightToLeft( .T. )
        this.SetLanguage( \"Hebrew\" )
      ENDCASE
    ENDIF
ENDDEFINE

How to Demo your App in Swahili Today

INTL is designed to be implemented quickly.

Here’s what you need to do to localize your application this morning for a multilingual demo this afternoon. If you\’ve used VFP\’s design tools properly, this is a quick job. If not, this will take a tad longer to engineer.

The basic steps are:

Install INTL and seed the Init() method of your form base classes.
Follow the steps in the section titled Installing INTL. Make sure you review all the steps. Especially important are the steps titled How to Instantiate an INTL Object, How to Get Automatic Form Localization, and How to Localize Menus.

Modify the structure of strings.dbf and add one field for each language you need.

  • Copy the strings.dbf table that comes with INTL and put it in your project root directory.
  • ZAP the strings.dbf table that you placed in your project root.
  • MODIFY STRUCTURE of strings.dbf and add a new column named cSwahili with a length of 120. Note that the \”c\” in cSwahili is required.

Make your application create an INTL object. Early in your application, instantiate an INTL object as described in How to Instantiate an INTL Object. Displaying in a different language is now a matter of using its SetLanguage() method.

Do a “Build All”. Open your project, select \”Build\”, and build an App or Exe, being sure to select \”Recompile All Files\”. Go to lunch.

To automatically load strings.dbf, either run your app or use the INTLTool utility. There are two ways to populate the strings.dbf table with your project\’s interface strings. The first way is to run your program. As objects are instantiated, INTL will append the strings (like Caption, Tooltiptext, etc.) into the strings table. A better way is to run the INTLTool update program. See INTLTool.

Input the translations in the strings.dbf table. In the cSwahili column, type-in Swahili translations, complete with hot-keys and shortcut-keys as required.
Note: you can get a \”quick-and-dirty\” translation for testing and internal demos by doing:

`REPLACE ALL cSwahili with \"**\"+TRIM(cOriginal)+\"**\" FOR cOriginal <> \"((\"`

How to Configure Your Main INTL Object

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 an amalgam of other INTL objects called hooks or strategies. Your main INTL object is the master INTL object in your environment, which I assume is 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 (Default)
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 RightToLeft strategy

Example: create an INTL object that localizes strings and fonts

*-- create an INTL object
_SCREEN.AddObject(\"oINTL\", \"INTL\" )
*-- Load the strings and font strategies.
_SCREEN.oINTL.SetConfig( 1 + 2 )

The operative language and locale of the main INTL object are configured
with the SetLanguage() and SetLocale() methods.

How to Configure Strategies

Strategies are bitwise configured.

Configuring individual strategies as follows: 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 DynamicFontSize
Picture 1 (Default)
2
4 (Default)
8
Picture
DownPicture
Icon
DragIcon
RightToLeft 1 (Default) All objects reversed within their respective containers
Strings 1 (Default)
2 (Default)
4 (Default)
Caption
ToolTipText
StatusBarText

To get a handle on a loaded strategy, use the oINTL.GetStrategy() method.
Thereafter, use the handle\’s oINTL.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 oINTL.SetConfig() method to configure it.

*-- create an INTL object
_SCREEN.AddObject(\"oINTL\", \"INTL\" )
*-- Load the strings and font strategies.
_SCREEN.oINTL.SetConfig( 3 )
*-- Configure Strings to NOT localize ToolTips
LOCAL loTempHandle
loTempHandle = _SCREEN.oINTL.GetStrategy( \"String\" )
*-- For the string strategy, the configuration
*-- for Caption and StatusBarText is 5
loTempHandle.SetConfig( 1 + 4 )

Example: create an INTL object that localizes only strings and
InputMasks.

*-- create an INTL object
_SCREEN.AddObject( \"oINTL\", \"INTL\" )
*-- Load the strings and data strategies.
_SCREEN.oINTL.SetConfig( 5 )
*-- now modify the data strategy from its default.
LOCAL oTemp
oTemp = _SCREEN.oINTL.GetStrategy( \"Data\" )
*-- Input masks only.
oTemp.SetConfig( 16 )

How to Localize Strings

Interface strings are usually the first things that come to mind when we think of translating software.

INTL loads only the string strategy by default.

The following 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)
4
2
8
16
32
cINTLString strategy loaded
cINTLFont strategy loaded
cINTLData strategy loaded
cINTLPicture strategy loaded
cINTLCurrency strategy loaded
cINTLRightToLeft strategy loaded
CINTLString 1 (Default)
2 (Default)
3 (Default)
Caption
ToolTipText
StatusBarText

Activate the string strategy as follows:

*-- cINTLString is loaded by default.
*-- So there’s usually no need to do this
_SCREEN.oINTL.SetStrategy( \"String\", \"cINTLString\" )

Another more cryptic way to load the String strategy is:

-- Set configuration bit 2^0 \"ON\"
_SCREEN.oINTL.SetConfig( BITSET( oINTL.GetConfig(), 0 ))

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:

*-- Get a handle on the string strategy:
oFont = _SCREEN.oINTL.GetStrategy( \"String\" )
*-- We want Caption( 1 ) and StatusbarText( 4 ) only
oFont.SetConfig( 5 )

How to Localize Fonts

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
cINTLString strategy loaded
cINTLFont strategy loaded
cINTLData strategy loaded
cINTLPicture strategy loaded
cINTLCurrency strategy loaded
cINTLRightToLeft strategy loaded
CINTLFont 1 (Default)
2 (Default)
Font and FontSize
DynamicFont and DynamicFontSize

Activate the font strategy as follows:

*-- cINTLFont is the Font strategy class.
_SCREEN.oINTL.SetStrategy( \"Font\", \"cINTLFont\" )

Another more cryptic way to load the Font strategy is:

*-- Set configuration bit 2^1 \"ON\"
_SCREEN.oINTL.SetConfig(BITSET(oINTL.GetConfig(),1 ))

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 ))”, 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:

*-- Set Font localization on
oINTL.SetConfig( BITSET( oINTL.GetConfig(), 1 )) && Set 2^1 \"ON\"
*-- Get a handle on the font strategy:
oFont = _SCREEN.oINTL.GetStrategy(\"Font\" )
*-- We want Font and FontSize and to disable DynamicFont
*-- and DynamicFontSize
oFont.SetConfig( 1 )

How to Localize Data Sources

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 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
cINTLString strategy loaded
cINTLFont strategy loaded
cINTLData strategy loaded
cINTLPicture strategy loaded
cINTLCurrency strategy loaded
cINTLRightToLeft strategy loaded
CINTLData 1 (Default)
2
4
8
16
BoundColumn
ControlSource
RowSource
RecordSource
InpuMask

Activate the data strategy as follows:

*-- cINTLData is the Graphics strategy class.
_SCREEN.oINTL.SetStrategy( \"Data\", \"cINTLData\" )

Another more cryptic way to load the Data strategy is:

*-- Set configuration bit 2^2 \"ON\"
_SCREEN.oINTL.SetConfig(BITSET(oINTL.GetConfig(),2 ))

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 cRrussian
((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.

*-- Set Data localization on
*-- Set 2^2 \"ON\"
oINTL.SetConfig( BITSET( oINTL.GetConfig(), 2 ))
*-- Get a handle on the data strategy:
oData = _SCREEN.oINTL.GetStrategy(\"Data\" )
*-- We want ControlSource (2)
*-- property localized.
oPicture.SetConfig( 2 )

How to Localize Pictures

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 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
cINTLString strategy loaded
cINTLFont strategy loaded
cINTLData strategy loaded
cINTLPicture strategy loaded
cINTLCurrency strategy loaded
cINTLRightToLeft strategy loaded
cINTLPicture 1 (Default)
2
4 (Default)
8
Picture
DownPicture
Icon
DragIcon

Activate the picture strategy as follows:

*-- cINTLPicture is the Graphics strategy class.
_SCREEN.oINTL.SetStrategy( \"Picture\", \"cINTLPicture\" )

Another more cryptic way to load the Picture strategy is:

*-- Set configuration bit 2^3 \"ON\"
_SCREEN.oINTL.SetConfig(BITSET(oINTL.GetConfig(),3 ))

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))”,
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.

*-- Set Picture localization on
*-- Set 2^3 \"ON\"
oINTL.SetConfig( BITSET( oINTL.GetConfig(), 3 ))
*-- Get a handle on the font strategy:
oPicture = _SCREEN.oINTL.GetStrategy(\"Picture\" )
*-- We want Picture (1), DownPicture( 2 ) and Icon (4)
*-- properties localized. 1+2+4 = 7
oPicture.SetConfig( 7 )

How to Localize Currencies

INTL provides a simple yet adaptable multi-currency capability.

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 (Default)
2
4
8
16
32
cINTLString strategy loaded
cINTLFont strategy loaded
cINTLData strategy loaded
cINTLPicture strategy loaded
cINTLCurrency strategy loaded
cINTLRightToLeft strategy loaded

Activate the currency strategy as follows:

Use oINTL.SetConfig() or oINTL.SetStrategy() to load the Currency strategy.

OINTL = _SCREEN.oINTL
oINTL.SetStratrgy( \"Currency\", \"cINTLCurrency\" )

An alternate (and more cryptic) way is to use INTL\’s SetConfig() method to make INTL invoke the Font strategy of a given class, as follows:

OINTL = _SCREEN.oINTL
*-- Set bit 2^4 \"ON\"
oINTL.SetConfig( BITSET( oINTL.GetConfig(), 4 ))

So there are two ways to do it.

The Currency strategy is not like the others. The INTL toolkit currency strategy is a little different from other strategies in three important respects:

  • currencies are locale-specific, not language-specific.

  • class cINTLCurrency does not use class cINTLString services, and

  • class cINTLCurrency makes many input fields read-only when the data is in a converted state.

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 cINTLCurrency to do anything you need it to do, such as lookups.

Let\’s configure INTL for the following currencies: Canadian dollar, Euro, 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. Then localize as usual.

oINTL = _SCREEN.oINTL

*-- Load the currency strategy
*-- Set 2^4 \"ON\"
oINTL.SetConfig( BITSET( oINTL.GetConfig(), 4 ))
*-- Define a few locales and currencies
oINTL.SetConversion( \"Canada\", 1 )
oINTL.SetConversion( \"Euro\", 1.55 )
oINTL.SetConversion( \"USA\", 1.33 )

*-- Lets assume we want to see it in US dollars
oINTL.SetLocale( \"USA\" )

*-- Localize the current form
oINTL.Localize(_SCREEN.ActiveForm )

How to Localize for Right-To-Left Writing Systems

INTL will automatically make your form objects display from right to left.

INTL enables you to display objects from right-to-left, which is required by Middle-Eastern writing systems. To do this, INTL reverses the location of objects within containers along the vertical centerline of the container. INTL also modifies the alignment property of checkboxes and option groups.

INTL does not change the orientation of caption text. To change the orientation of caption text, you must be using a Middle-Eastern localization of Windows.

The result is forms are reversed; if they were read from left-to-right now they read from right-to-left, and vice-versa.

Recall that INTL strategies are bitwise-configured according to the
following table:

Class (with default) Value Localization
INTL (1) 1 (Default)
2
4
8
16
32
cINTLString strategy loaded
cINTLFont strategy loaded
cINTLData strategy loaded
cINTLPicture strategy loaded
cINTLCurrency strategy loaded
cINTLRightToLeft strategy loaded

Activate the currency strategy as follows:

Use oINTL.SetConfig() or oINTL.SetStrategy() to load the Currency strategy.

OINTL = _SCREEN.oINTL
oINTL.SetStratrgy( \"RightToLeft\", \"cINTLRightToLeft\" )
An alternate (and more cryptic ) way is to use INTL\'s `SetConfig()` method make INTL invoke the Font strategy of a given class, as follows:
OINTL = _SCREEN.oINTL<b
*-- Set bit 2^5 \"ON\"
oINTL.SetConfig( BITSET( oINTL.GetConfig(), 5 ))

So there are two ways to do it.

The RightToLeft strategy is the only strategy that actually rearranges objects in containers.

The INTL toolkit right-to-left strategy is a little different from other strategies in four important respects:

  • The right-to-left writing direction is locale-specific and language-specific.
  • Class cINTLRightToLeft does not use class cINTLString services.
  • Class cINTLRightToLeft reverses the location of objects within containers along the container\’s vertical axis. What was on the left ends up on the right, and vice versa. Also the alignment property of Checkboxes and Optiongroups is reversed, as is the sequences of Pages in Pageframes and Columns in grids.
  • If you develop in a right-to-left writing system, you can use a cINTLRightToLeft strategy to write from left-to-right.

Let\’s configure INTL for a right-to-left language. The cleanest way to do this is with a subclass of the INTL::SetLanguage() method. Alternately, you could also do it with the SetLocale() method. Either way, the implementation is the same.

In this example, we use SetLanguage() to configure for the RightToLeft transformation.

Note: for clarity we\’ve omitted configuring for the Font strategy, which we would probably need to do. See How to Localize Fonts.

DEFINE CLASS MidEastINTL AS INTL
  FUNCTION SetLanguage( tcLanguage )
    LOCAL llRetVal
    LlRetVal = INTL::SetLanguage( tcLanguage )
    *-- The right-to-left strategy is configured
    *-- with the fifth INTL configuration bit.
    IF tcLanguage = \"Hebrew\" OR ;
      TcLanguage = \"Arabic\"
      this.SetConfig( BITSET( this.GetConfig(), 5 ))
    ELSE
      this.SetConfig( BITCLEAR( this.GetConfig(), 5 ))
    ENDIF
    RETURN llRetVal
ENDDEFINE

How to Subclass an Existing Strategy

Need different behavior? Consider a subclass. You may encounter situations where you need to do thing differently. Instead of changing the INTL source code (which will create difficulties when merging future releases) consider subclassing an existing strategy for desired behavior.

In the diagram below, we\’ve created two subclasses, one from the
cINTLString class and one from the cINTLCurrency class. The class
hierarchy now looks like this:

New classes added to the INTL class hierarchy.

To use your subclasses instead of those that ship with INTL, call the
setstrategy()method as follows:

*-- Assuming _SCREEN.oINTL is already Instantiated
_SCREEN.oINTL.SetStrategy(\"String\", \"cMyString\" )
_SCREEN.oINTL.SetStrategy(\"Currency\", \"cMyCurrency\" )

How to Create Your Own Generic Strategy

You can create your own strategies and use INTL to automatically invoke
them. 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!

As in the case of subclassing an existing strategy, use the
SetStrategy() method to load your strategy into INTL.

How to Make INTL Ignore an Object

Three ways:

  • You can make INTL ignore an object or a container object by placing
    the string \”INTL Ignore\” in the object\’s comment property. This
    string is not case sensitive.

  • If you can, give your object\’s class an INTL property, and assign it
    logical .F.

  • If you can, give your object\’s class an INTL property, and assign it
    a numeric value of less than 0.

How to Make INTL Treat an Object Differently

If you have special needs for a particular object, give your object\’s
class an INTL property, and assign a numeric value to the property in
the class definition or to this object\’s instance. This numeric value is
the value you would assign to INTL\’s SetConfig() method to configure
INTL for this particular object.

How to Substitute Your Own Strategies

If you wish to substitute your own strategies in subsequent strategy
instantiations, use the SetStrategyClass() method to assign a new
strategy class to an existing strategy alias.

*-- Permanently install cMyStringStrategy for the string strategy.
_SCREEN.oINTL.SetStrategyClass( \"String\", \"cMyStringStrategy\" )

How to Batch-Update strings.dbf

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.

See Updating strings.dbf Based on a .PJX.

How to Localize Reports

VFP report structures are not generated or compiled — they are bound
into your application \”as-is\”. Reports must therefore be transformed
before the .APP or .EXE is created.

Localizing reports is something you really only need to do once. 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:\").

See Transforming Reports Based on a .PJX.

Details of How INTL Works

If you plan to get really fancy with swapping languages on the fly, it
will be helpful to know the following things:

  • After INTL localizes a form, it adds to the form an object named
    oINTL of class cINTLMemento configured as INTL was configured. This
    memento is a lightweight object that allows several INTL objects to
    peacefully co-exist because they can know that a particular Form is,
    at this moment, displaying in, say, Japanese.

  • When an INTL object finds a form containing a member named oINTL, it
    will adopt the member\’s configuration as determined by its
    GETCONFIG() value.

If you need alternate behavior — for example if you need the second INTL
object to completely override a memento from the first — then first
localize the form back to original (which removes the Form.oINTL member)
and then localize to the new locale using the second INTL object.

Details of How MsgSvc() Works

Upon first invocation, MsgSvc() creates an object named _SCREEN.oMsgSvc
which thereafter will manage messaging. If an object named
_SCREEN.oINTL exists, the _SCREEN.MsgSvc object will obey its language
settings and use its services.

How to Distribute INTL Files

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 You’ll 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.

Toolkit File Descriptions

Here\’s a description of the files used by INTL. To reckon where these
can be best placed relative to your project, see How to Correctly Place Your INTL Files.

File Description
addendum.txt Late breaking news that may or may not be included in the documentation or the help file.
genmenux.zip An archive of the latest available GENMENUX program by Andrew Ross MacNeill.
i.prg A stand-alone function that serves as a shortcut to the _SCREEN.oINTL.I() method.
intl.prg The core code for the classes and utilities in the INTL toolkit.
intltool.prg Developer’s utilities to do batch operations on project files and other VFP structures. Do not distribute this file with your applications.
msgsvc.dbf
msgsvc.fpt
msgsvc.cdx
Table and supporting files containing messages for dialogs, wait windows, thermometer bars and text blocks.
msgsvc.prg The message services library.
nohot.prg nohot() strips hot key characters from FoxPro prompt expressions. It is a one-line function that you should cut and paste as a procedure somewhere in your application’s invocation stack.
strings.dbf
strings.fpt
strings.cdx
Table and supporting files containing translated phrases.

Overview of the INTL Class Library

The INTL class hierarchy is based on class cINTLAbstract. cINTLAbstract serves to define the interface for the entire hierarchy. Wherever possible, adding rogue properties, events, and methods to subclasses has been avoided.

The figure below shows an OMT diagram of the INTL class hierarchy.

The INTL class hierarchy.

In normal circumstances, the only objects you’ll probably use are of
class INTL.

Class cINTLMemento can be used as a token.

cINTLMemento is a configuration token that INTL objects may use to store details of a specific localization. cINTLMemento includes access methods to protected properties.

INTL is the public interface and template methods for the localization
process.

cINTLStrategy is the Parentclass of various localization engines.

cINTLString, cINTLCurrency, cINTLFont, cINTLMeasures, cINTLPicture, and cINTLData are classes of specific strategic implementations.

Class INTL

The INTL class provides services to localize objects and other elements
in your application.

Class INTL Exposed Properties

INTL::cCurrencyStrategy

INTL allows you to localize currencies.

A string specifying the name of the currency strategy class.

Default \"cINTLCurrency\"
Remarks You may subclass cINTLCurrency to suit your particular needs. You may then use the SetStrategy(\"Currency\",cYourCurrencyClass) method to set this currency strategy property to something other than the default.
See Also cINTLMemento::GetStrategy()

INTL::cDataStrategy

INTL allows different data sources for different locales. A string specifying the name of the data strategy class.

<markdown-accessibl

下载源码

通过命令行克隆项目:

git clone https://github.com/StevenBlack/intl.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 编程相关 intl https://www.zuozi.net/33476.html

Solitaire
上一篇: Solitaire
CosaNostra HTTP Botnet
下一篇: CosaNostra HTTP Botnet
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务