Class LanguageData
License: GNU General Public License v2.0 only **********************************************************************************************
Brief:
Stores language data in a class object
This class stores data of the Language object. These are the paths to all relevant language files, the configured language and the default language. This object is designed to be stored in a PHP session. The Language object itself couldn't be stored in a Session because it uses PHP objects which couldn't stored in a PHP session.
Class: LanguageData
Code:
// show how to use this class with the language 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')); @endcode
Par: Examples
Located at languagedata.php
Methods summary
public
|
#
__construct( string $language, string $languagePath = '' )
Creates an object that stores all necessary language data and can be handled in session. Therefore the language must be set and optional a path where the language files are stored. |
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. |
public
string[]
|
|
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[]
|
|
public
|
#
setCountriesArray( array $countries )
Save the array with all countries and their ISO codes in an internal parameter for later use |
public
|
#
setLanguage( string $language )
Set a language to this object. If there was a language before than initialize the cache |
Properties summary
public
array
|
$textCache
|
#
array()
|
private
array
|
$languageFilePath
|
#
array()
|
private
|
$language
|
|
private
string
|
$referenceLanguage
|
#
'en'
|
private
array
|
$countries
|
#
array()
|