Language
Languages/translation handler class
since |
1.0 |
---|---|
package |
Joomla Framework |
Methods
_
Translate function, mimics the php gettext (alias _) function.
_(string string, bool jsSafe = false, bool interpretBackSlashes = true) : string
The function checks if $jsSafe is true, then if $interpretBackslashes is true.
see | Language::translate() |
---|---|
since |
1.0 |
deprecated |
3.0 Use translate instead |
Arguments
- string
string
The string to translate- jsSafe
bool
Make the result JavaScript safe- interpretBackSlashes
bool
Interpret \t and \n
Response
string
The translation of the string
__construct
Constructor activating the default information of the language.
__construct(\Joomla\Language\ParserRegistry parserRegistry, string path, string lang = '', bool debug = false) : mixed
since |
1.0 |
---|
Arguments
- parserRegistry
\Joomla\Language\ParserRegistry
A registry containing the supported file parsers- path
string
The base path to the language folder- lang
string
The language- debug
bool
Indicates if language debugging is enabled
Response
mixed
debugFile
Debugs a language file
debugFile(string filename) : int
since |
2.0.0-alpha |
---|
Arguments
- filename
string
Absolute path to the file to debug
Response
int
A count of the number of parsing errors
exists
Checks if a language exists.
exists(string lang, string basePath = '') : bool
This is a simple, quick check for the directory that should contain language files for the given user.
see | LanguageHelper::exists() |
---|---|
since |
1.0 |
deprecated |
3.0 Use LanguageHelper::exists() instead |
Arguments
- lang
string
Language to check.- basePath
string
Optional path to check.
Response
bool
True if the language exists.
get
Get a metadata language property.
get(string property, mixed default = null) : mixed
since |
1.0 |
---|
Arguments
- property
string
The name of the property.- default
mixed
The default value.
Response
mixed
The value of the property.
getBasePath
Get the base path for the instance.
getBasePath() : string
since |
2.0.0-alpha |
---|
Response
string
getCallerInfo
Determine who called Language or Text.
getCallerInfo() : mixed
since |
1.0 |
---|
Response
mixed
Caller information or null if unavailable
getCatalogue
Get the message catalogue for the language.
getCatalogue() : \Joomla\Language\MessageCatalogue
since |
2.0.0-alpha |
---|
Response
\Joomla\Language\MessageCatalogue
getDebug
Get the Debug property.
getDebug() : bool
since |
1.0 |
---|
Response
bool
True is in debug mode.
getDefault
Get the default language code.
getDefault() : string
since |
1.0 |
---|
Response
string
Language code.
getErrorFiles
Get a list of language files that are in error state.
getErrorFiles() : array
since |
1.0 |
---|
Response
array
getFirstDay
Get the first day of the week for this language.
getFirstDay() : int
since |
1.0 |
---|
Response
int
The first day of the week according to the language
getKnownLanguages
Returns a list of known languages for an area
getKnownLanguages(string basePath = '') : array
see | LanguageHelper::getKnownLanguages() |
---|---|
since |
1.0 |
deprecated |
3.0 Use LanguageHelper::getKnownLanguages() instead |
Arguments
- basePath
string
The basepath to use
Response
array
key/value pair with the language file and real name.
getLanguage
Get the current language code.
getLanguage() : string
since |
1.0 |
---|
Response
string
The language code
getLanguagePath
Get the path to a language
getLanguagePath(string basePath = '', string language = '') : string
see | LanguageHelper::getLanguagePath() |
---|---|
since |
1.0 |
deprecated |
3.0 Use LanguageHelper::getLanguagePath() instead |
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 |
1.0 |
---|
Response
array
The locale according to the language.
getMetadata
Returns a associative array holding the metadata.
getMetadata(string lang, string basePath) : mixed
see | LanguageHelper::getMetadata() |
---|---|
since |
1.0 |
deprecated |
3.0 Use LanguageHelper::getMetadata() instead |
Arguments
- lang
string
The name of the language.- basePath
string
The filepath to the language folder.
Response
mixed
If $lang exists return key/value pair with the language metadata, otherwise return NULL.
getName
Getter for Name.
getName() : string
since |
1.0 |
---|
Response
string
Official name element of the language.
getOrphans
Get the list of orphaned strings if being tracked.
getOrphans() : array
since |
1.0 |
---|
Response
array
Orphaned text.
getPaths
Get a list of language files that have been loaded.
getPaths(string extension = null) : array
since |
1.0 |
---|
Arguments
- extension
string
An optional extension name.
Response
array
getPluralSuffixes
Returns an array of suffixes for plural rules.
getPluralSuffixes(int count) : string[]
since |
1.0 |
---|
Arguments
- count
int
The count number the rule is for.
Response
string[]
The array of suffixes.
getTag
Getter for the language tag (as defined in RFC 3066)
getTag() : string
since |
1.0 |
---|
Response
string
The language tag.
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 |
1.0 |
---|
Response
array
Used strings.
getWeekEnd
Get the weekends days for this language.
getWeekEnd() : string
since |
2.0.0-alpha |
---|
Response
string
The weekend days of the week separated by a comma according to the language
hasKey
Determines is a key exists.
hasKey(string string) : bool
since |
1.0 |
---|
Arguments
- string
string
The key to check.
Response
bool
True, if the key exists.
isRtl
Get the RTL property.
isRtl() : bool
since |
1.0 |
---|
Response
bool
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 = '', string lang = null, bool reload = false) : bool
since |
1.0 |
---|
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
bool
Flag that will force a language to be reloaded if set to true.
Response
bool
True if the file has successfully loaded.
loadLanguage
Loads a language file.
loadLanguage(string filename, string extension = 'unknown') : bool
This method will not note the successful loading of a file - use load() instead.
see | Language::load() |
---|---|
since |
1.0 |
Arguments
- filename
string
The name of the file.- extension
string
The name of the extension.
Response
bool
True if new strings have been added to the language
parse
Parses a language file.
parse(string filename) : array
since |
1.0 |
---|
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
see | LanguageHelper::parseLanguageFiles() |
---|---|
since |
1.0 |
deprecated |
3.0 Use LanguageHelper::parseLanguageFiles() instead |
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) : mixed
see | LanguageHelper::parseXMLLanguageFile() |
---|---|
since |
1.0 |
deprecated |
3.0 Use LanguageHelper::parseXMLLanguageFile() instead |
Arguments
- path
string
Path to the XML files.
Response
mixed
Array holding the found metadata as a key => value pair or null on an invalid XML file
setCatalogue
Set the message catalogue for the language.
setCatalogue(\Joomla\Language\MessageCatalogue catalogue) : void
since |
2.0.0-alpha |
---|
Arguments
- catalogue
\Joomla\Language\MessageCatalogue
The message catalogue to use.
setDebug
Set the Debug property.
setDebug(bool debug) : bool
since |
1.0 |
---|
Arguments
- debug
bool
The debug setting.
Response
bool
Previous value.
setDefault
Set the default language code.
setDefault(string lang) : string
since |
1.0 |
---|
Arguments
- lang
string
The language code.
Response
string
Previous value.
translate
Translate function, mimics the php gettext (alias _) function.
translate(string string, bool jsSafe = false, bool interpretBackSlashes = true) : string
The function checks if $jsSafe is true, then if $interpretBackslashes is true.
since |
2.0.0-alpha |
---|
Arguments
- string
string
The string to translate- jsSafe
bool
Make the result JavaScript safe- interpretBackSlashes
bool
Interpret \t and \n
Response
string
The translation of the 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 |
1.0 |
---|---|
throws |
|
Arguments
- string
string
The string to transliterate.
Response
string
The transliteration of the string.
Properties
debug
Debug language, If true, highlights if string isn't found.
since |
1.0 |
---|
Type(s)
bool
default
The default language, used when a language file in the requested language does not exist.
since |
1.0 |
---|
Type(s)
string
orphans
An array of orphaned text.
since |
1.0 |
---|
Type(s)
array
metadata
Array holding the language metadata.
since |
1.0 |
---|
Type(s)
array
locale
Array holding the language locale or boolean null if none.
since |
1.0 |
---|
Type(s)
array|bool
lang
The language to load.
since |
1.0 |
---|
Type(s)
string
paths
A nested array of language files that have been loaded
since |
1.0 |
---|
Type(s)
array
errorfiles
List of language files that are in error state
since |
1.0 |
---|
Type(s)
array
used
An array of used text, used during debugging.
since |
1.0 |
---|
Type(s)
array
counter
Counter for number of loads.
since |
1.0 |
---|
Type(s)
int
override
An array used to store overrides.
since |
1.0 |
---|
Type(s)
array
localise
The localisation object.
since |
2.0.0-alpha |
---|
Type(s)
\Joomla\Language\LocaliseInterface
helper
LanguageHelper object
since |
2.0.0-alpha |
---|
Type(s)
\Joomla\Language\LanguageHelper
basePath
The base path to the language folder
since |
2.0.0-alpha |
---|
Type(s)
string
catalogue
MessageCatalogue object
since |
2.0.0-alpha |
---|
Type(s)
\Joomla\Language\MessageCatalogue
parserRegistry
Language parser registry
since |
2.0.0-alpha |
---|
Type(s)
\Joomla\Language\ParserRegistry