class Language

Languages/translation handler class

Methods

__construct( string $lang = null, boolean $debug = false)

Constructor activating the default information of the language.

static  Language
getInstance( string $lang, boolean $debug = false)

Returns a language object.

string
_( string $string, boolean $jsSafe = false, boolean $interpretBackSlashes = true)

Translate function, mimics the php gettext (alias _) function.

string
transliterate( string $string)

Transliterate function

callable
getTransliterator()

Getter for transliteration function

callable
setTransliterator( callable $function)

Set the transliteration function.

array
getPluralSuffixes( integer $count)

Returns an array of suffixes for plural rules.

callable
getPluralSuffixesCallback()

Getter for pluralSuffixesCallback function.

callable
setPluralSuffixesCallback( callable $function)

Set the pluralSuffixes function.

array
getIgnoredSearchWords()

Returns an array of ignored search words

callable
getIgnoredSearchWordsCallback()

Getter for ignoredSearchWordsCallback function.

callable
setIgnoredSearchWordsCallback( callable $function)

Setter for the ignoredSearchWordsCallback function

integer
getLowerLimitSearchWord()

Returns a lower limit integer for length of search words

callable
getLowerLimitSearchWordCallback()

Getter for lowerLimitSearchWordCallback function

callable
setLowerLimitSearchWordCallback( callable $function)

Setter for the lowerLimitSearchWordCallback function.

integer
getUpperLimitSearchWord()

Returns an upper limit integer for length of search words

callable
getUpperLimitSearchWordCallback()

Getter for upperLimitSearchWordCallback function

callable
setUpperLimitSearchWordCallback( callable $function)

Setter for the upperLimitSearchWordCallback function

integer
getSearchDisplayedCharactersNumber()

Returns the number of characters displayed in search results.

callable
getSearchDisplayedCharactersNumberCallback()

Getter for searchDisplayedCharactersNumberCallback function

callable
setSearchDisplayedCharactersNumberCallback( callable $function)

Setter for the searchDisplayedCharactersNumberCallback function.

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

Checks if a language exists.

boolean
load( string $extension = 'joomla', string $basePath = JPATH_BASE, string $lang = null, boolean $reload = false, boolean $default = true)

Loads a single language file and appends the results to the existing strings

integer
debugFile( string $filename)

Debugs a language file

mixed
get( string $property, mixed $default = null)

Get a metadata language property.

string
getName()

Getter for Name.

array
getPaths( string $extension = null)

Get a list of language files that have been loaded.

array
getErrorFiles()

Get a list of language files that are in error state.

string
getTag()

Getter for the language tag (as defined in RFC 3066)

string
getCalendar()

Getter for the calendar type

boolean
isRtl()

Get the RTL property.

boolean
setDebug( boolean $debug)

Set the Debug property.

boolean
getDebug()

Get the Debug property.

string
getDefault()

Get the default language code.

string
setDefault( string $lang)

Set the default language code.

array
getOrphans()

Get the list of orphaned strings if being tracked.

array
getUsed()

Get the list of used strings.

boolean
hasKey( string $string)

Determines is a key exists.

static  mixed
getMetadata( string $lang)

Returns an associative array holding the metadata.

static  array
getKnownLanguages( string $basePath = JPATH_BASE)

Returns a list of known languages for an area

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

Get the path to a language

string
setLanguage( string $lang)

Set the language attributes to the given language.

array
getLocale()

Get the language locale based on current language.

integer
getFirstDay()

Get the first day of the week for this language.

string
getWeekEnd()

Get the weekends days for this language.

static  array
parseLanguageFiles( string $dir = null)

Searches for language directories within a certain base dir.

static  array
parseXMLLanguageFile( string $path)

Parse XML file for language information.

Details

__construct( string $lang = null, boolean $debug = false)

Constructor activating the default information of the language.

Parameters

string $lang The language
boolean $debug Indicates if language debugging is enabled.

static Language getInstance( string $lang, boolean $debug = false)

Returns a language object.

Parameters

string $lang The language to use.
boolean $debug The debug mode.

Return Value

Language The Language object.

string _( string $string, boolean $jsSafe = false, boolean $interpretBackSlashes = true)

Translate function, mimics the php gettext (alias _) function.

The function checks if $jsSafe is true, then if $interpretBackslashes is true.

Parameters

string $string The string to translate
boolean $jsSafe Make the result javascript safe
boolean $interpretBackSlashes Interpret \t and \n

Return Value

string The translation of the string

string transliterate( string $string)

Transliterate function

This method processes a string and replaces all accented UTF-8 characters by unaccented ASCII-7 "equivalents".

Parameters

string $string The string to transliterate.

Return Value

string The transliteration of the string.

callable getTransliterator()

Getter for transliteration function

Return Value

callable The transliterator function

callable setTransliterator( callable $function)

Set the transliteration function.

Parameters

callable $function Function name or the actual function.

Return Value

callable The previous function.

array getPluralSuffixes( integer $count)

Returns an array of suffixes for plural rules.

Parameters

integer $count The count number the rule is for.

Return Value

array The array of suffixes.

callable getPluralSuffixesCallback()

Getter for pluralSuffixesCallback function.

Return Value

callable Function name or the actual function.

callable setPluralSuffixesCallback( callable $function)

Set the pluralSuffixes function.

Parameters

callable $function Function name or actual function.

Return Value

callable The previous function.

array getIgnoredSearchWords()

Returns an array of ignored search words

Return Value

array The array of ignored search words.

callable getIgnoredSearchWordsCallback()

Getter for ignoredSearchWordsCallback function.

Return Value

callable Function name or the actual function.

callable setIgnoredSearchWordsCallback( callable $function)

Setter for the ignoredSearchWordsCallback function

Parameters

callable $function Function name or actual function.

Return Value

callable The previous function.

integer getLowerLimitSearchWord()

Returns a lower limit integer for length of search words

Return Value

integer The lower limit integer for length of search words (3 if no value was set for a specific language).

callable getLowerLimitSearchWordCallback()

Getter for lowerLimitSearchWordCallback function

Return Value

callable Function name or the actual function.

callable setLowerLimitSearchWordCallback( callable $function)

Setter for the lowerLimitSearchWordCallback function.

Parameters

callable $function Function name or actual function.

Return Value

callable The previous function.

integer getUpperLimitSearchWord()

Returns an upper limit integer for length of search words

Return Value

integer The upper limit integer for length of search words (200 if no value was set or if default value is < 200).

callable getUpperLimitSearchWordCallback()

Getter for upperLimitSearchWordCallback function

Return Value

callable Function name or the actual function.

callable setUpperLimitSearchWordCallback( callable $function)

Setter for the upperLimitSearchWordCallback function

Parameters

callable $function Function name or the actual function.

Return Value

callable The previous function.

integer getSearchDisplayedCharactersNumber()

Returns the number of characters displayed in search results.

Return Value

integer The number of characters displayed (200 if no value was set for a specific language).

callable getSearchDisplayedCharactersNumberCallback()

Getter for searchDisplayedCharactersNumberCallback function

Return Value

callable Function name or the actual function.

callable setSearchDisplayedCharactersNumberCallback( callable $function)

Setter for the searchDisplayedCharactersNumberCallback function.

Parameters

callable $function Function name or the actual function.

Return Value

callable The previous function.

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

Checks if a language exists.

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

Parameters

string $lang Language to check.
string $basePath Optional path to check.

Return Value

boolean True if the language exists.

boolean load( string $extension = 'joomla', string $basePath = JPATH_BASE, string $lang = null, boolean $reload = false, boolean $default = true)

Loads a single language file and appends the results to the existing strings

Parameters

string $extension The extension for which a language file should be loaded.
string $basePath The basepath to use.
string $lang The language to load, default null for the current language.
boolean $reload Flag that will force a language to be reloaded if set to true.
boolean $default Flag that force the default language to be loaded if the current does not exist.

Return Value

boolean True if the file has successfully loaded.

integer debugFile( string $filename)

Debugs a language file

Parameters

string $filename Absolute path to the file to debug

Return Value

integer A count of the number of parsing errors

Exceptions

InvalidArgumentException

mixed get( string $property, mixed $default = null)

Get a metadata language property.

Parameters

string $property The name of the property.
mixed $default The default value.

Return Value

mixed The value of the property.

string getName()

Getter for Name.

Return Value

string Official name element of the language.

array getPaths( string $extension = null)

Get a list of language files that have been loaded.

Parameters

string $extension An optional extension name.

Return Value

array

array getErrorFiles()

Get a list of language files that are in error state.

Return Value

array

string getTag()

Getter for the language tag (as defined in RFC 3066)

Return Value

string The language tag.

string getCalendar()

Getter for the calendar type

Return Value

string The calendar type.

boolean isRtl()

Get the RTL property.

Return Value

boolean True is it an RTL language.

boolean setDebug( boolean $debug)

Set the Debug property.

Parameters

boolean $debug The debug setting.

Return Value

boolean Previous value.

boolean getDebug()

Get the Debug property.

Return Value

boolean True is in debug mode.

string getDefault()

Get the default language code.

Return Value

string Language code.

string setDefault( string $lang)

Set the default language code.

Parameters

string $lang The language code.

Return Value

string Previous value.

array getOrphans()

Get the list of orphaned strings if being tracked.

Return Value

array Orphaned text.

array getUsed()

Get the list of used strings.

Used strings are those strings requested and found either as a string or a constant.

Return Value

array Used strings.

boolean hasKey( string $string)

Determines is a key exists.

Parameters

string $string The key to check.

Return Value

boolean True, if the key exists.

static mixed getMetadata( string $lang)

Returns an associative array holding the metadata.

Parameters

string $lang The name of the language.

Return Value

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

static array getKnownLanguages( string $basePath = JPATH_BASE)

Returns a list of known languages for an area

Parameters

string $basePath The basepath to use

Return Value

array key/value pair with the language file and real name.

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

Get the path to a language

Parameters

string $basePath The basepath to use.
string $language The language tag.

Return Value

string language related path or null.

string setLanguage( string $lang)

Set the language attributes to the given language.

Once called, the language still needs to be loaded using Language::load().

Parameters

string $lang Language code.

Return Value

string Previous value.

array getLocale()

Get the language locale based on current language.

Return Value

array The locale according to the language.

integer getFirstDay()

Get the first day of the week for this language.

Return Value

integer The first day of the week according to the language

string getWeekEnd()

Get the weekends days for this language.

Return Value

string The weekend days of the week separated by a comma according to the language

static array parseLanguageFiles( string $dir = null)

Searches for language directories within a certain base dir.

Parameters

string $dir directory of files.

Return Value

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

static array parseXMLLanguageFile( string $path)

Parse XML file for language information.

Parameters

string $path Path to the XML files.

Return Value

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

Exceptions

RuntimeException