Sahi Pro - Multi Language Support

abstract Websites may be enabled in multiple languages like English, Spanish, Chinese etc. Sahi's multi-language support allows
testing of websites in any language using the same scripts as long as translations are available.

In most applications, Internationalization (I18N) and Localization (L10N) are done by specifying constant keys in web application code,
and then having another layer substitute these constant keys with the correct language translations provided via property files.

Since Sahi's scripts rely on visible text, the scripts may be recorded with English text. To play it on the German version,
the script needs to be passed the English and German property files with localized values.
When Sahi encounters an English string, it will look up the corresponding key in the English file, then lookup the German value for that key in
the German.properties file and then use that value during execution.

_setLanguage

Since Sahi Pro: 6.2.0
Since Sahi OS: NA

_setLanguage($translateTo, $translateFrom)

Arguments
$translateTostring Path to properties file for language to translate to (eg. for English to German, this may be German.properties). Paths are relative to script.
$translateFromstring Path to properties file for language to translate from (eg. for English to German, this may be en_us.properties). Paths are relative to script.

Details

Sets the language in which the script will be executed.

Example:
Assume a web application with a button which shows up as "Thank You" in English and "Danke" in German.

If the script was recorded on the English version, it would look like:

_click(_button("Thank You"));

If the code was to be executed on the German site, it would fail because the button there says "Danke".

If this application had been internationalized, it would have property files with the correct translations.
Eg.

# en.properties
...
THANK_YOU=Thank You
... other keys

# german.properties
...
THANK_YOU=Danke
... other keys

Modify the Sahi script and provide these translation files:
_setLanguage("german.properties", "en.properties");
_click(_button("Thank You"));

This will actually execute
_click(_button("Danke"));
on the browser.

Controlling Translation

Do NOT Translate. Use String Literal (L:)

If a string should not be translated, it can be prefixed with "L:"
Eg.
_setLanguage("german.properties", "en.properties");
_log("L:Hi there!"); // will print "Hi there!"

Provide the Key itself, instead of reverse look up (K:)

Eg.
_setLanguage("german.properties", "en.properties");
_log("K:THANK_YOU"); // will print "Danke"