LocalizedTexts object

.html ›› .html ›› .html ››
Parent Previous Next

LocalizedTexts object

This object represents an isolated context for working with translations without modifying the plugin translations itself. 

You can create a new instance of this object by calling Locale.newLocalizedTexts()

Object characteristics

Methods

Método

Descrição

obj:addText(localeId, textId, text)


Add a single translation entry to the LocalizedTexts object.


Arguments:

    • localeId - A string containing the identification of the locale, in BCP 47 format, in which this text should be used. Examples: "pt", "pt-BR", "en", "en-US", and so on. Nil or empty string means undefined.
    • textId - A string containing the identification of the text. This textId is used when searching translations with translations with obj:lang() and/or obj:tryLang().
    • text - A string containing the translated text.


obj:lang(textId)

Search for a translation to be used for the current user's language.


Arguments:

    • textId - A string containing the identification of the text.


Returns:

    • A string containing the translated text.


Remarks:

    • If the search does not find text for the user's language, the function will return a string from another language. 
    • The function raises an error if "textId" does not exist in any language.


obj:loadTexts(langTexts)


Loads a ".lang" file so that more translated text can be found by the obj:lang() and obj:tryLang() methods.


Arguments:

    • langTexts - A string with the contents of the .lang file that will be loaded


Remarks:


obj:tryLang(textId)


This function works similarly to the obj:lang() method, except it does not raise an error if the text entry does not exist. In such a case, a nil value is returned.


Created with the Personal Edition of HelpNDoc: Free Kindle producer