Ask Reuben

Localization Inversion

With localization, how can I change the order of words to match the language convention? 

How can I avoid having M * N localization entries, and have M + N entries.

With localized strings  you can fall into a trap where you have localizations for the string tokens %”p1″,%”p2″,%”p1 p2″ i.e.

"p1" = "Foo"
"p2" = "Bar"
"p1 p2"  = "Foo Bar"

With M p1’s, N p2’s, this is a total of M+N+M*N string tokens to maintain per language

Using SFMT you can reduce this by coding SFMT(%”p1.p2″, %”p1″, %”p2″) and having in your localization

"p1" = "Foo"
"p2" = "Bar"
"p1.p2"  = "%1 %2"

This will now leave you with a total of M+N+1 string tokens to maintain per language.

( The above is a gross simplification but hopefully you get the idea)

In linguistics terms, the concept of inversion is where the order of terms in a sentence may differ.  Using SFMT and the above concept, this is catered for because for that language you might have as your entry for p1.p2, the parameters reversed i.e

"p1.p2"  = "%2 %1"

and now the order of the terms in the output is reversed.

To do a little experiment, code ..

$! askreuben80.4gl
MAIN
    DISPLAY %"p1"
    DISPLAY %"p2"
    DISPLAY SFMT(%"p1.p2",%"p1",%"p2")
END MAIN

#! askreuben80.str
"p1" = "Foo"
"p2" = "Bar"
"p1.p2" = "%1 %2"

You should get as output …

Foo
Bar
Foo Bar

Now change the last string token

"p1.p2" = "%2 %1"

and you should now get

Foo
Bar
Bar Foo

Some examples of this are given in the best practises page for localized strings, but hopefully you get the idea that you can include %1, %2 etc in your localized strings,  use SFMT to replace them, and switch the order of the parameters in the localized string as required by the language.