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?        

Common

NameReturnSummary 
LanguageTranslator::addFileToTranslate(string $filename)
string boolGiven a source file to translate, create a new textdomain 
LanguageTranslator::commonTranslation(string $str)
stringGet a common translation 
LanguageTranslator::encodeJSON($value)
stringJSON encode language translation data 
LanguageTranslator::filenameToTextdomain(string $filename)
stringGiven a filename, convert it to a textdomain string 
LanguageTranslator::findTranslation(string $text)
string arrayFind a translation for given text 
LanguageTranslator::findTranslations(string $text)
arrayFind all translation(s) for given text 
LanguageTranslator::getTextdomain(string $textdomain)
arrayReturn the data available for the given $textdomain string 
LanguageTranslator::getTranslation($textdomain, string $text)
string array falseImplementation for the getTranslation() function - you should call getTranslation() without underscores instead.
LanguageTranslator::getTranslationInfo($textdomain, string $text)
arrayGet verbose array of information about translation 
LanguageTranslator::getTranslationOrFalse($textdomain, string $text)
string falseGet translated text or boolean false if not translated (rather than default language value) 
LanguageTranslator::getTranslations($textdomain)
arrayReturn ALL translations for the given textdomain 
LanguageTranslator::loadTextdomain(string $textdomain)
$thisLoad translation group $textdomain into the current language translations 
LanguageTranslator::removeTranslation(string $textdomain, string $hash)
$thisRemove a translation 
LanguageTranslator::saveTextdomain(string $textdomain)
int boolSave the translation group given by $textdomain to disk in its translation file 
LanguageTranslator::setCurrentLanguage(Language $language)
$thisSet the current language and reset current stored textdomains 
LanguageTranslator::setTranslation(string $textdomain, string $text, string $translation)
stringSet a translation 
LanguageTranslator::setTranslationFromHash(string $textdomain, string $hash, string $translation)
stringSet a translation using an already known hash 
LanguageTranslator::textdomainFileExists(string $textdomain)
boolDoes a json translation file exist for the given textdomain? 
LanguageTranslator::textdomainString($textdomain)
stringNormalize a string, filename or object to be a textdomain string 
LanguageTranslator::textdomainToFilename(string $textdomain)
stringGiven a textdomain string, convert it to a filename (relative to site root) 
LanguageTranslator::unloadTextdomain(string $textdomain)
(nothing)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.244

Latest news

  • ProcessWire Weekly #558
    In the 558th issue of ProcessWire Weekly we'll check out the blog post that introduces ProcessWire 3.0.244, share some recent ProcessWire highlights, and more. Read on!
    Weekly.pw / 18 January 2025
  • ProcessWire 3.0.244 new main/master version
    ProcessWire 3.0.244 is our newest main/master/stable version. It's been more than a year in the making and is packed with tons of new features, issue fixes, optimizations and more. This post covers all the details.
    Blog / 18 January 2025
  • Subscribe to weekly ProcessWire news

“…building with ProcessWire was a breeze, I really love all the flexibility the system provides. I can’t imagine using any other CMS in the future.” —Thomas Aull