Banana.Translations.Translator

文件资料 •
在此文中

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);
Tell us how we can help you better
If the information on this page is not what you're looking for, is not clear enough, or is not up-to-date, let us know.

分享这篇文章: Twitter | Facebook | LinkedIn | Email