LanguageTranslator class

Located in file /wire/modules/LanguageSupport/LanguageTranslator.php

Click any linked item for full usage details and examples. Hookable methods are indicated with the icon. In addition to those shown below, the LanguageTranslator class also inherits all the methods and properties of: Wire.

Show class?     Show args?       Only hookable?    

Common

NameReturnSummary 
LanguageTranslator::addFileToTranslate(string $filename)
string bool

Given a source file to translate, create a new textdomain

 
LanguageTranslator::commonTranslation(string $str)
string

Get a common translation

 
LanguageTranslator::encodeJSON($value)
string

JSON encode language translation data

 
LanguageTranslator::filenameToTextdomain(string $filename)
string

Given a filename, convert it to a textdomain string

 
LanguageTranslator::findTranslation(string $text)
string array

Find a translation for given text

 
LanguageTranslator::findTranslations(string $text)
array

Find all translation(s) for given text

 
LanguageTranslator::getTextdomain(string $textdomain)
array

Return the data available for the given $textdomain string

 
LanguageTranslator::getTranslation($textdomain, string $text)
string array false

Implementation for the getTranslation() function - you should call getTranslation() without underscores instead.

LanguageTranslator::getTranslationInfo($textdomain, string $text)
array

Get verbose array of information about translation

 
LanguageTranslator::getTranslationOrFalse($textdomain, string $text)
string false

Get translated text or boolean false if not translated (rather than default language value)

 
LanguageTranslator::getTranslations($textdomain)
array

Return ALL translations for the given textdomain

 
LanguageTranslator::loadTextdomain(string $textdomain)
$this

Load translation group $textdomain into the current language translations

 
LanguageTranslator::removeTranslation(string $textdomain, string $hash)
$this

Remove a translation

 
LanguageTranslator::saveTextdomain(string $textdomain)
int bool

Save the translation group given by $textdomain to disk in its translation file

 
LanguageTranslator::setCurrentLanguage(Language $language)
$this

Set the current language and reset current stored textdomains

 
LanguageTranslator::setTranslation(string $textdomain, string $text, string $translation)
string

Set a translation

 
LanguageTranslator::setTranslationFromHash(string $textdomain, string $hash, string $translation)
string

Set a translation using an already known hash

 
LanguageTranslator::textdomainFileExists(string $textdomain)
bool

Does a json translation file exist for the given textdomain?

 
LanguageTranslator::textdomainString($textdomain)
string

Normalize a string, filename or object to be a textdomain string

 
LanguageTranslator::textdomainToFilename(string $textdomain)
string

Given a textdomain string, convert it to a filename (relative to site root)

 
LanguageTranslator::unloadTextdomain(string $textdomain)
None

Unload the given textdomain string from memory

 

Additional methods and properties

In addition to the methods and properties above, LanguageTranslator also inherits the methods and properties of these classes:

API reference based on ProcessWire core version 3.0.252