Localization Technique

Discussion created by alex_zueiv on Apr 5, 2018

There was a question on the FMPexperts mailing lists about localization technique. I though it could be interesting to others, so I decided to publish it here, too. This is a kind of standard localization technique that all software use, .strings file interpreted as FMP table.


1. Create a table with one regular text field and one repeating field with as many repetitions as languages you will use. For example, for English, French and Spanish:


Table: StringsTable


StrName (Text)

StrValue (Text, 3 repetitions)


Fill in the first field with label names, and the second, with their translations. For example:


IDB_SORT_ORDER Sort Ascending | Trier par ordre croissant | Ordenar de forma ascendente

IDB_SORT_ORDER_DESCEND Sort Descending | Trier par ordre décroissant | Ordenar de forma descendente

IDB_SORT_ORDER_CUSTOM Custom Sort Order | Ordre de tri personnalisé | Orden personalizado


(" | " is used here to show separate repetitions)


2. Create the following custom function:


// TranslateFieldName ( FieldReference ; LanguageNum )

// 2018-04-05 by Alex Zueiv

// WARNING: Contains hardcoded table and fields references!


ExecuteSQL ( "SELECT StrValue[" & GetAsNumber ( LanguageNum ) & "] FROM StringsTable WHERE StrName=?" ; "" ; "" ; GetValue ( Substitute ( GetFieldName ( FieldReference ) ; "::" ; ¶ ) ; 2 ) )


3. Create a table with a global number field for the currently chosen language and one calculated global field per each text label. For example:


LanguageNumber (Number, Global)

IDB_SORT_ORDER (Text, Global Calculation) = TranslateFieldName ( Self ; LanguageNumber )

IDB_SORT_ORDER_DESCEND (Text, Global Calculation) = TranslateFieldName ( Self ; LanguageNumber )

IDB_SORT_ORDER_CUSTOM (Text, Global Calculation) = TranslateFieldName ( Self ; LanguageNumber )


Now you can use these globals as localizable field/button labels or dialog strings. Download the attached file to try it out.