Banana.Translations.Translator

Documentation •
In this article

The class Banana.Translations.Translator let you translate strings.

Properties

context

Returns the context of the translator.

language

Returns the language of the translator.

valid

Returns true if the translator is valid.

An invalid translator simply returns the text untranslated as written in the source code.

Methods

tr(text [, disambiguation , n])

Translate a string in the language and context of the translator


// Get translator for the document's language
var documentLanguage = "en"; //default
if (Banana.document) {
    documentLanguage = Banana.document.locale.substring(0,2);
}
var docTranslator = Banana.Translations.getTranslator(documentLanguage, "MyReport");

// Translate to the document's language
var myReportTranslatedText = docTranslator.tr(myReportTexts.account_card);

translate(context, text [, disambiguation , n])

Translate a string in the language of the translator in the specified context.


// Get translator for the document's language
var documentLanguage = "en"; //default
if (Banana.document) {
    documentLanguage = Banana.document.locale.substring(0,2);
}
var docTranslator = Banana.Translations.getTranslator(documentLanguage, "MyReport");

// Translate to the document's language
var myReportTranslatedText = docTranslator.translate("MyReport", myReportTexts.account_card);

Help us improve the documentation

We welcome feedback on how to improve this page.

Tell us what theme needs a better explanation or how to clarify a topic.

Share this article: Twitter | Facebook | LinkedIn | Email