Class Language
License: GNU General Public License v2.0 only **********************************************************************************************
Brief:
Reads language specific texts that are identified with text ids out of language xml files
The class will read a language specific text that is identified with their text id out of an language xml file. The access will be manages with the SimpleXMLElement which search through xml files. An object of this class can't be stored in a PHP session because it creates PHP core objects which couldn't be stored in sessions. Therefore an object of @b LanguageData should be assigned to this class that stored all necessary data and can be stored in a session.
Class: Language
Code:
// show how to use this class with the language data class and sessions script_a.php // create a language data object and assign it to the language object $language = new Language(); $languageData = new LanguageData('de'); $language->addLanguageData($languageData); $session->addObject('languageData', $languageData);
script_b.php // read language data from session and add it to language object $language = new Language(); $language->addLanguageData($session->getObject('languageData'));
// read and display a language specific text with placeholders for individual content echo $gL10n->get('MAI_EMAIL_SEND_TO_ROLE_ACTIVE', 'John Doe', 'Demo-Organization', 'Administrator');@endcode
Par: Examples
Located at language.php
Methods summary
public
|
#
addLanguageData(
Adds a language data object to this class. The object contains all necessary language data that is stored in the PHP session. |
public
|
#
addLanguagePath( string $path )
Adds a new path of language files to the array with all language paths where Admidio should search for language files. |
protected
string
|
#
getTextFromTextId( string $textId )
Reads a text string out of a language xml file that is identified with a unique text id e.g. SYS_COMMON. |
public
string
|
|
public
string[]
|
|
public
string
|
#
getCountryByCode( string $isoCode )
Returns the name of the country in the language of this object. The country will be identified by the ISO code e.g. 'DEU' or 'GBR' ... |
public
string|false
|
#
getCountryByName( string $country )
Returns the three digits ISO code of the country. The country will be identified by the name in the language of this object |
public
string
|
#
getLanguageIsoCode( boolean $referenceLanguage = false )
Returns the ISO code of the language of this object. |
public
string
|
#
getLanguage( boolean $referenceLanguage = false )
Returns the language code of the language of this object. This is the code that is set within Admidio with some specials like de_sie. If you only want the ISO code then call getLanguageIsoCode(). |
public
string[]
|
#
getAvailableLanguages( )
Creates an array with all languages that are possible in Admidio. The array will have the following syntax e.g.: array('DE' => 'deutsch' ...) |
public
string
|
#
searchLanguageText( array & $objectArray, string $languagePath, string $language, string $textId )
Search for text id in a language xml file and return the text. If no text was found than nothing is returned. |
public
|
#
setLanguage( string $language )
Set a language to this object. If there was a language before than initialize the cache |
Properties summary
private
|
$languageData
|
|
private
array
|
$languages
|
#
array()
|
private
array
|
$xmlLanguageObjects
|
#
array()
|
private
array
|
$xmlReferenceLanguageObjects
|
#
array()
|