LanguageHelper

Language helper class

since

1.5

Methods

createLanguageList

Builds a list of the system languages which can be used in a select option

createLanguageList(string $actualLanguage, string $basePath = JPATH_BASE, boolean $caching = false, boolean $installed = false) : array
static
since

1.5

Arguments

$actualLanguage

stringClient key for the area

$basePath

stringBase path to use

$caching

booleanTrue if caching is used

$installed

booleanGet only installed languages

Response

arrayList of system languages

detectLanguage

Tries to detect the language.

detectLanguage() : string
static
since

1.5

Response

stringlocale or null if not found

exists

Checks if a language exists.

exists(string $lang, string $basePath = JPATH_BASE) : boolean
static

This is a simple, quick check for the directory that should contain language files for the given user.

since

3.7.0

Arguments

$lang

stringLanguage to check.

$basePath

stringOptional path to check.

Response

booleanTrue if the language exists.

getContentLanguages

Get a list of content languages.

getContentLanguages(array $publishedStates = array(1), boolean $checkInstalled = true, string $pivot = 'lang_code', string $orderField = null, string $orderDirection = null) : array
static
since

3.7.0

Arguments

$publishedStates

arrayArray with the content language published states. Empty array for all.

$checkInstalled

booleanCheck if the content language is installed.

$pivot

stringThe pivot of the returning array.

$orderField

stringField to order the results.

$orderDirection

stringDirection to order the results.

Response

arrayArray of the content languages.

getInstalledLanguages

Get a list of installed languages.

getInstalledLanguages(integer $clientId = null, boolean $processMetaData = false, boolean $processManifest = false, string $pivot = 'element', string $orderField = null, string $orderDirection = null) : array
static
since

3.7.0

Arguments

$clientId

integerThe client app id.

$processMetaData

booleanFetch Language metadata.

$processManifest

booleanFetch Language manifest.

$pivot

stringThe pivot of the returning array.

$orderField

stringField to order the results.

$orderDirection

stringDirection to order the results.

Response

arrayArray with the installed languages.

getKnownLanguages

Returns a list of known languages for an area

getKnownLanguages(string $basePath = JPATH_BASE) : array
static
since

3.7.0

Arguments

$basePath

stringThe basepath to use

Response

arraykey/value pair with the language file and real name.

getLanguagePath

Get the path to a language

getLanguagePath(string $basePath = JPATH_BASE, string $language = null) : string
static
since

3.7.0

Arguments

$basePath

stringThe basepath to use.

$language

stringThe language tag.

Response

stringlanguage related path or null.

getLanguages

Get available languages

getLanguages(string $key = 'default') : array
static
since

1.6

Arguments

$key

stringArray key

Response

arrayAn array of published languages

getMetadata

Returns an associative array holding the metadata.

getMetadata(string $lang) : mixed
static
since

3.7.0

Arguments

$lang

stringThe name of the language.

Response

mixedIf $lang exists return key/value pair with the language metadata, otherwise return NULL.

parseIniFile

Parse strings from a language file.

parseIniFile(string $fileName, boolean $debug = false) : boolean
static
since

3.9.0

Arguments

$fileName

stringThe language ini file path.

$debug

booleanIf set to true debug language ini file.

Response

booleanTrue if saved, false otherwise.

parseLanguageFiles

Searches for language directories within a certain base dir.

parseLanguageFiles(string $dir = null) : array
static
since

3.7.0

Arguments

$dir

stringdirectory of files.

Response

arrayArray holding the found languages as filename => real name pairs.

parseXMLLanguageFile

Parse XML file for language information.

parseXMLLanguageFile(string $path) : array
static
since

3.7.0

throws

\RuntimeException

Arguments

$path

stringPath to the XML files.

Response

arrayArray holding the found metadata as a key => value pair.

saveToIniFile

Save strings to a language file.

saveToIniFile(string $fileName, array $strings) : boolean
static
since

3.7.0

Arguments

$fileName

stringThe language ini file path.

$strings

arrayThe array of strings.

Response

booleanTrue if saved, false otherwise.