Class Language
Defines the language class used for translating system strings by using po
files for different languages.
Methods summary
public
|
#
__construct( string $directory, string $language = null )
Initialize the language class for translating strings.
Initialize the language class for translating strings.
Parameters
- $directory
string $directory Path to directory that holds po files.
- $language
string $language The language code from \Peg\Custom\Localization\LanguageCode
Throws
ExceptionIf language directory doesn't exists.
|
public
string
|
#
GetLanguage( )
Current language used for translation output.
Current language used for translation output.
Returns
string One of the values from \Peg\Custom\Localization\LanguageCode
|
public
string
|
#
GetSystemLangauge( )
Gets the current system language.
Gets the current system language.
Returns
string One of the values from \Peg\Custom\Localization\LanguageCode
Todo
Implement also for microsoft windows.
|
public
|
#
SetLanguage( string $language = null )
Assings the language for translation output. If no language is given the
system one is assigned.
Assings the language for translation output. If no language is given the
system one is assigned.
Parameters
- $language
string $language One of the values from \Peg\Custom\Localization\LanguageCode
|
public
string
|
#
Translate( string $text )
Translates a given text to the currently language set.
Translates a given text to the currently language set.
Parameters
- $text
string $text String to translate.
Returns
string Translated text or original if no translation found.
|
public
array
|
#
PoParser( string $file )
Parses a .po file generated by gettext tools.
Parses a .po file generated by gettext tools.
Parameters
- $file
string $file The path of the po translations file.
Returns
array In the format array["original text"] = "translation"
|