JLanguage
Extends \JObjectLanguages/translation handler class
This class allows for simple but smart objects with get and set methods and an internal error handler.
package |
Joomla.Platform |
---|---|
subpackage |
Language |
since |
11.1 |
Methods
_
Translate function, mimics the php gettext (alias _) function.
_(string $string, boolean $jsSafe = false, boolean $interpretBackSlashes = true) : string
The function checks if $jsSafe is true, then if $interpretBackslashes is true.
since |
11.1 |
---|
Arguments
- $string
string
The string to translate- $jsSafe
boolean
Make the result javascript safe- $interpretBackSlashes
boolean
Interpret \t and \n
Response
string
The translation of the string
__construct
Class constructor, overridden in descendant classes.
__construct(mixed $properties = null)
since |
11.1 |
---|
Arguments
- $properties
mixed
Either and associative array or another object to set the initial properties of the object.
__toString
Magic method to convert the object to a string gracefully.
__toString() : string
since |
11.1 |
---|---|
deprecated |
12.3 Classes should provide their own __toString() implementation. |
Response
string
The classname.
_parseLanguageFiles
Searches for language directories within a certain base dir.
_parseLanguageFiles(string $dir = null) : array
deprecated |
12.1 |
---|---|
note |
Use parseLanguageFiles instead. |
since |
11.1 |
Arguments
- $dir
string
Directory of files.
Response
array
Array holding the found languages as filename => real name pairs.
_parseXMLLanguageFile
Parse XML file for language information.
_parseXMLLanguageFile(string $path) : array
deprecated |
12.1 |
---|---|
note |
Use parseXMLLanguageFile instead. |
since |
11.1 |
Arguments
- $path
string
Path to the XML files.
Response
array
Array holding the found metadata as a key => value pair.
_parseXMLLanguageFiles
Parses XML files for language information.
_parseXMLLanguageFiles(string $dir = null) : array
note |
Use parseXMLLanguageFiles instead. |
---|---|
since |
11.1 |
deprecated |
12.1 |
Arguments
- $dir
string
Directory of files.
Response
array
Array holding the found languages as filename => metadata array.
def
Sets a default value if not alreay assigned
def(string $property, mixed $default = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
exists
Checks if a language exists.
exists(string $lang, string $basePath = JPATH_BASE) : boolean
This is a simple, quick check for the directory that should contain language files for the given user.
since |
11.1 |
---|
Arguments
- $lang
string
Language to check.- $basePath
string
Optional path to check.
Response
boolean
True if the language exists.
get
Returns a property of the object or the default value if the property is not set.
get(string $property, mixed $default = null) : mixed
since |
11.1 |
---|---|
see | \JObject::getProperties() |
Arguments
- $property
string
The name of the property.- $default
mixed
The default value.
Response
mixed
The value of the property.
getCallerInfo
Determine who called JLanguage or JText.
getCallerInfo() : array
since |
11.1 |
---|
Response
array
Caller information.
getDebug
Get the Debug property.
getDebug() : boolean
since |
11.1 |
---|
Response
boolean
True is in debug mode.
getDefault
Get the default language code.
getDefault() : string
since |
11.1 |
---|
Response
string
Language code.
getError
Get the most recent error message.
getError(integer $i = null, boolean $toString = true) : string
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $i
integer
Option error index.- $toString
boolean
Indicates if JError objects should return their error message.
Response
string
Error message
getErrorFiles
Get a list of language files that are in error state.
getErrorFiles() : array
since |
11.1 |
---|
Response
array
getErrors
Return all errors, if any.
getErrors() : array
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Response
array
Array of error messages or JErrors.
getFirstDay
Get the first day of the week for this language.
getFirstDay() : integer
since |
11.1 |
---|
Response
integer
The first day of the week according to the language
getIgnoredSearchWords
Returns an array of ignored search words
getIgnoredSearchWords() : array
since |
11.1 |
---|
Response
array
The array of ignored search words.
getIgnoredSearchWordsCallback
Getter for ignoredSearchWordsCallback function.
getIgnoredSearchWordsCallback() : mixed
since |
11.1 |
---|
Response
mixed
Function name (string) or the actual function for PHP 5.3 (function).
getInstance
Returns a language object.
getInstance(string $lang, boolean $debug = false) : \JLanguage
since |
11.1 |
---|
Arguments
- $lang
string
The language to use.- $debug
boolean
The debug mode.
Response
\JLanguage
The Language object.
getKnownLanguages
Returns a list of known languages for an area
getKnownLanguages(string $basePath = JPATH_BASE) : array
since |
11.1 |
---|
Arguments
- $basePath
string
The basepath to use
Response
array
key/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
since |
11.1 |
---|
Arguments
- $basePath
string
The basepath to use.- $language
string
The language tag.
Response
string
language related path or null.
getLocale
Get the language locale based on current language.
getLocale() : array
since |
11.1 |
---|
Response
array
The locale according to the language.
getLowerLimitSearchWord
Returns a lower limit integer for length of search words
getLowerLimitSearchWord() : integer
since |
11.1 |
---|
Response
integer
The lower limit integer for length of search words (3 if no value was set for a specific language).
getLowerLimitSearchWordCallback
Getter for lowerLimitSearchWordCallback function
getLowerLimitSearchWordCallback() : mixed
since |
11.1 |
---|
Response
mixed
Function name (string) or the actual function for PHP 5.3 (function).
getMetadata
Returns a associative array holding the metadata.
getMetadata(string $lang) : mixed
since |
11.1 |
---|
Arguments
- $lang
string
The name of the language.
Response
mixed
If $lang exists return key/value pair with the language metadata, otherwise return NULL.
getName
Getter for Name.
getName() : string
since |
11.1 |
---|
Response
string
Official name element of the language.
getOrphans
Get the list of orphaned strings if being tracked.
getOrphans() : array
since |
11.1 |
---|
Response
array
Orphaned text.
getPaths
Get a list of language files that have been loaded.
getPaths(string $extension = null) : array
since |
11.1 |
---|
Arguments
- $extension
string
An optional extension name.
Response
array
getPluralSufficesCallback
Getter for pluralSuffixesCallback function.
getPluralSufficesCallback() : mixed
since |
11.1 |
---|---|
deprecated |
12.1 |
note |
Use JLanguage::getPluralSuffixesCallback method instead |
Response
mixed
Function name (string) or the actual function for PHP 5.3 (function).
getPluralSuffixes
Returns an array of suffixes for plural rules.
getPluralSuffixes(integer $count) : array
since |
11.1 |
---|
Arguments
- $count
integer
The count number the rule is for.
Response
array
The array of suffixes.
getPluralSuffixesCallback
Getter for pluralSuffixesCallback function.
getPluralSuffixesCallback() : mixed
since |
11.1 |
---|
Response
mixed
Function name (string) or the actual function for PHP 5.3 (function).
getProperties
Returns an associative array of object properties.
getProperties(boolean $public = true) : array
since |
11.1 |
---|---|
see | \JObject::get() |
Arguments
- $public
boolean
If true, returns only the public properties.
Response
array
getSearchDisplayedCharactersNumber
Returns the number of characters displayed in search results.
getSearchDisplayedCharactersNumber() : integer
since |
11.1 |
---|
Response
integer
The number of characters displayed (200 if no value was set for a specific language).
getSearchDisplayedCharactersNumberCallback
Getter for searchDisplayedCharactersNumberCallback function
getSearchDisplayedCharactersNumberCallback() : mixed
since |
11.1 |
---|
Response
mixed
Function name or the actual function for PHP 5.3.
getTag
Getter for the language tag (as defined in RFC 3066)
getTag() : string
since |
11.1 |
---|
Response
string
The language tag.
getTransliterator
Getter for transliteration function
getTransliterator() : string
since |
11.1 |
---|
Response
string
Function name or the actual function for PHP 5.3.
getUpperLimitSearchWord
Returns an upper limit integer for length of search words
getUpperLimitSearchWord() : integer
since |
11.1 |
---|
Response
integer
The upper limit integer for length of search words (20 if no value was set for a specific language).
getUpperLimitSearchWordCallback
Getter for upperLimitSearchWordCallback function
getUpperLimitSearchWordCallback() : string|\function
since |
11.1 |
---|
Response
string|\function
Function name or the actual function for PHP 5.3.
getUsed
Get the list of used strings.
getUsed() : array
Used strings are those strings requested and found either as a string or a constant.
since |
11.1 |
---|
Response
array
Used strings.
hasKey
Determines is a key exists.
hasKey(string $string) : boolean
since |
11.1 |
---|
Arguments
- $string
string
The key to check.
Response
boolean
True, if the key exists.
isRTL
Get the RTL property.
isRTL() : boolean
since |
11.1 |
---|
Response
boolean
True is it an RTL language.
load
Loads a single language file and appends the results to the existing strings
load(string $extension = 'joomla', string $basePath = JPATH_BASE, string $lang = null, boolean $reload = false, boolean $default = true) : boolean
since |
11.1 |
---|
Arguments
- $extension
string
The extension for which a language file should be loaded.- $basePath
string
The basepath to use.- $lang
string
The language to load, default null for the current language.- $reload
boolean
Flag that will force a language to be reloaded if set to true.- $default
boolean
Flag that force the default language to be loaded if the current does not exist.
Response
boolean
True if the file has successfully loaded.
loadLanguage
Loads a language file.
loadLanguage(string $filename, string $extension = 'unknown', boolean $overwrite = true) : boolean
This method will not note the successful loading of a file - use load() instead.
see | \JLanguage::load() |
---|---|
since |
11.1 |
Arguments
- $filename
string
The name of the file.- $extension
string
The name of the extension.- $overwrite
boolean
Not used??
Response
boolean
True if new strings have been added to the language
parse
Parses a language file.
parse(string $filename) : array
since |
11.1 |
---|
Arguments
- $filename
string
The name of the file.
Response
array
The array of parsed strings.
parseLanguageFiles
Searches for language directories within a certain base dir.
parseLanguageFiles(string $dir = null) : array
since |
11.1 |
---|
Arguments
- $dir
string
directory of files.
Response
array
Array holding the found languages as filename => real name pairs.
parseXMLLanguageFile
Parse XML file for language information.
parseXMLLanguageFile(string $path) : array
since |
11.1 |
---|
Arguments
- $path
string
Path to the XML files.
Response
array
Array holding the found metadata as a key => value pair.
parseXMLLanguageFiles
Parses XML files for language information
parseXMLLanguageFiles(string $dir = null) : array
since |
11.1 |
---|
Arguments
- $dir
string
Directory of files.
Response
array
Array holding the found languages as filename => metadata array.
set
Modifies a property of the object, creating it if it does not already exist.
set(string $property, mixed $value = null) : mixed
since |
11.1 |
---|
Arguments
- $property
string
The name of the property.- $value
mixed
The value of the property to set.
Response
mixed
Previous value of the property.
setDebug
Set the Debug property.
setDebug(boolean $debug) : boolean
since |
11.1 |
---|
Arguments
- $debug
boolean
The debug setting.
Response
boolean
Previous value.
setDefault
Set the default language code.
setDefault(string $lang) : string
since |
11.1 |
---|
Arguments
- $lang
string
The language code.
Response
string
Previous value.
setError
Add an error message.
setError(string $error) : void
since |
11.1 |
---|---|
see | \JError |
deprecated |
12.3 JError has been deprecated |
Arguments
- $error
string
Error message.
setIgnoredSearchWordsCallback
Setter for the ignoredSearchWordsCallback function
setIgnoredSearchWordsCallback(mixed $function) : mixed
since |
11.1 |
---|
Arguments
- $function
mixed
Function name (string) or actual function for PHP 5.3 (function)
Response
mixed
Function name (string) or the actual function for PHP 5.3 (function)
setLanguage
Set the language attributes to the given language.
setLanguage(string $lang) : string
Once called, the language still needs to be loaded using JLanguage::load().
since |
11.1 |
---|
Arguments
- $lang
string
Language code.
Response
string
Previous value.
setLowerLimitSearchWordCallback
Setter for the lowerLimitSearchWordCallback function.
setLowerLimitSearchWordCallback(mixed $function) : string|\function
since |
11.1 |
---|
Arguments
- $function
mixed
Function name (string) or actual function for PHP 5.3 (function)
Response
string|\function
Function name or the actual function for PHP 5.3.
setPluralSuffixesCallback
Set the pluralSuffixes function.
setPluralSuffixesCallback(mixed $function) : mixed
since |
11.1 |
---|
Arguments
- $function
mixed
Function name (string) or actual function for PHP 5.3 (function)
Response
mixed
Function name or the actual function for PHP 5.3.
setProperties
Set the object properties based on a named array/hash.
setProperties(mixed $properties) : boolean
since |
11.1 |
---|---|
see | \JObject::set() |
Arguments
- $properties
mixed
Either an associative array or another object.
Response
boolean
setSearchDisplayedCharactersNumberCallback
Setter for the searchDisplayedCharactersNumberCallback function.
setSearchDisplayedCharactersNumberCallback(string $function) : mixed
since |
11.1 |
---|
Arguments
- $function
string
The name of the callback.
Response
mixed
Function name (string) or the actual function for PHP 5.3 (function).
setTransliterator
Set the transliteration function.
setTransliterator(mixed $function) : mixed
since |
11.1 |
---|
Arguments
- $function
mixed
Function name (string) or the actual function for PHP 5.3 (function).
Response
mixed
setUpperLimitSearchWordCallback
Setter for the upperLimitSearchWordCallback function
setUpperLimitSearchWordCallback(string $function) : mixed
since |
11.1 |
---|
Arguments
- $function
string
The name of the callback function.
Response
mixed
Function name (string) or the actual function for PHP 5.3 (function).
toString
Converts the object to a string (the class name).
toString() : string
transliterate
Transliterate function
transliterate(string $string) : string
This method processes a string and replaces all accented UTF-8 characters by unaccented ASCII-7 "equivalents".
since |
11.1 |
---|
Arguments
- $string
string
The string to transliterate.
Response
string
The transliteration of the string.
Properties
languages
Type(s)
debug
Debug language, If true, highlights if string isn't found.
since |
11.1 |
---|
Type(s)
boolean
default
The default language, used when a language file in the requested language does not exist.
since |
11.1 |
---|
Type(s)
string
orphans
An array of orphaned text.
since |
11.1 |
---|
Type(s)
array
metadata
Array holding the language metadata.
since |
11.1 |
---|
Type(s)
array
locale
Array holding the language locale or boolean null if none.
since |
11.1 |
---|
Type(s)
array|boolean
lang
The language to load.
since |
11.1 |
---|
Type(s)
string
paths
A nested array of language files that have been loaded
since |
11.1 |
---|
Type(s)
array
errorfiles
List of language files that are in error state
since |
11.1 |
---|
Type(s)
array
strings
Translations
since |
11.1 |
---|
Type(s)
array
used
An array of used text, used during debugging.
since |
11.1 |
---|
Type(s)
array
counter
Counter for number of loads.
since |
11.1 |
---|
Type(s)
integer
override
An array used to store overrides.
since |
11.1 |
---|
Type(s)
array
transliterator
Name of the transliterator function for this language.
since |
11.1 |
---|
Type(s)
string
pluralSuffixesCallback
Name of the pluralSuffixesCallback function for this language.
since |
11.1 |
---|
Type(s)
string
ignoredSearchWordsCallback
Name of the ignoredSearchWordsCallback function for this language.
since |
11.1 |
---|
Type(s)
string
lowerLimitSearchWordCallback
Name of the lowerLimitSearchWordCallback function for this language.
since |
11.1 |
---|
Type(s)
string
upperLimitSearchWordCallback
Name of the uppperLimitSearchWordCallback function for this language
since |
11.1 |
---|
Type(s)
string
searchDisplayedCharactersNumberCallback
Name of the searchDisplayedCharactersNumberCallback function for this language.
since |
11.1 |
---|
Type(s)
string
_errors
An array of error messages or Exception objects.