AddTranslation (add translation pairs)

Top  Previous  Next




( | group| )



| text, translation |


Adds translation pairs.


The label of a structure that contains one or more text/translation pairs.


A string constant, variable, EQUATE, or expression containing user interface text to search for. The TranslatorClass replaces each found text with its corresponding translation.


A string constant, variable, EQUATE, or expression containing the replacement text for the corresponding text.

The AddTranslation method adds translation pairs to the runtime translation process.

The text is not limited to a single word; it may contain a phrase, or any text string, including TranslatorClass macros (see TranslatorClass Concepts--Runtime Translation).


The group parameter must name a GROUP that begins the same as the TranslatorGroup structure declared in ABUTIL.INC:

TranslatorGroup GROUP,TYPE

Number           USHORT


When you declare a translation group, be sure to set the correct number of translation pairs in the GROUP. For example:

MyAppTranslator GROUP

Pairs            USHORT(2)                            !2 translation pairs

                PSTRING('&Insert')                   !begin 1st pair

                PSTRING('&Agregar')                  ! end 1st pair

                PSTRING('Insert a new Record')       !begin 2nd pair

                PSTRING('Agregar un nuevo Registro') !  end 2nd pair


The TranslatorClass uses whole word, case sensitive matching to search for text. For example, 'Insert' does not match '&Insert' or 'INSERT' or 'Insert a new Record.'

The Init method uses the AddTranslation method to add the translation pairs declared in ABUTIL.TRN to the translation process.

The various "Translate" methods apply the translation pairs.


MyTranslations GROUP                    !declare local translations

Pairs           USHORT(4)               !4 translations pairs

               PSTRING('&Sound')       ! item 1 text

               PSTRING('&xSoundx')     ! item 1 replacement text

               PSTRING('&Volume')      ! item 2 text

               PSTRING('&xVolumex')    ! item 2 replacement text

               PSTRING('Preferences')  ! item 3 text

               PSTRING('xPreferencesx')! item 3 replacement text

               PSTRING('OK')           ! item 4 text

               PSTRING('xOKx')         ! item 4 replacement text


Translator           TranslatorClass    !declare Translator object


Translator.Init                        !initialize Translator object

                                       !add default translation pairs

Translator.AddTranslation(MyTranslations) !add local translation pairs


Translator.TranslateWindow                !translate all window controls

                                          ! and window titlebar

See Also:     Init, TranslateControl, TranslatedControls, TranslateString, TranslateWindow