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 file and then use that value during execution.


Since Sahi Pro: 6.2.0
Since Sahi OS: NA

_setLanguage($translateTo, $translateFrom)

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


Sets the language in which the script will be executed.

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.

... other keys

... other keys

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

This will actually execute
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:"
_setLanguage("", "");
_log("L:Hi there!"); // will print "Hi there!"

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

_setLanguage("", "");
_log("K:THANK_YOU"); // will print "Danke"