PHP Class PrivateBin\I18n

provides internationalization tools like translation, browser language detection, etc.
Afficher le fichier Open project: privatebin/privatebin Class Usage Examples

Protected Properties

Свойство Type Description
$_availableLanguages array available languages
$_language string language
$_languageFallback string language fallback
$_languageLabels array language labels
$_path string path to language files
$_translations array translation cache

Méthodes publiques

Méthode Description
_ ( string $messageId ) : string translate a string, alias for translate()
getAvailableLanguages ( ) : array get list of available translations based on files found
getBrowserLanguages ( ) : array detect the clients supported languages and return them ordered by preference
getLanguage ( ) : string get currently loaded language
getLanguageLabels ( array $languages = [] ) : array get list of language labels
loadTranslations ( ) : void loads translations
setLanguageFallback ( string $lang ) : void set the default language
translate ( string $messageId ) : string translate a string

Méthodes protégées

Méthode Description
_getMatchingLanguage ( array $acceptedLanguages, array $availableLanguages ) : string compares two language preference arrays and returns the preferred match
_getPath ( string $file = '' ) : string get language file path
_getPluralForm ( integer $n ) : integer determines the plural form to use based on current language and given number
_matchLanguage ( string $a, string $b ) : float compare two language IDs and return the degree they match

Method Details

_() public static méthode

translate a string, alias for translate()
public static _ ( string $messageId ) : string
$messageId string
Résultat string

_getMatchingLanguage() protected static méthode

From: https://stackoverflow.com/questions/3770513/detect-browser-language-in-php#3771447
protected static _getMatchingLanguage ( array $acceptedLanguages, array $availableLanguages ) : string
$acceptedLanguages array
$availableLanguages array
Résultat string

_getPath() protected static méthode

get language file path
protected static _getPath ( string $file = '' ) : string
$file string
Résultat string

_getPluralForm() protected static méthode

From: http://localization-guide.readthedocs.org/en/latest/l10n/pluralforms.html
protected static _getPluralForm ( integer $n ) : integer
$n integer
Résultat integer

_matchLanguage() protected static méthode

From: https://stackoverflow.com/questions/3770513/detect-browser-language-in-php#3771447
protected static _matchLanguage ( string $a, string $b ) : float
$a string
$b string
Résultat float

getAvailableLanguages() public static méthode

get list of available translations based on files found
public static getAvailableLanguages ( ) : array
Résultat array

getBrowserLanguages() public static méthode

From: https://stackoverflow.com/questions/3770513/detect-browser-language-in-php#3771447
public static getBrowserLanguages ( ) : array
Résultat array

getLanguage() public static méthode

get currently loaded language
public static getLanguage ( ) : string
Résultat string

getLanguageLabels() public static méthode

Only for given language codes, otherwise all labels.
public static getLanguageLabels ( array $languages = [] ) : array
$languages array
Résultat array

loadTranslations() public static méthode

From: https://stackoverflow.com/questions/3770513/detect-browser-language-in-php#3771447
public static loadTranslations ( ) : void
Résultat void

setLanguageFallback() public static méthode

set the default language
public static setLanguageFallback ( string $lang ) : void
$lang string
Résultat void

translate() public static méthode

translate a string
public static translate ( string $messageId ) : string
$messageId string
Résultat string

Property Details

$_availableLanguages protected_oe static_oe property

available languages
protected static array $_availableLanguages
Résultat array

$_language protected_oe static_oe property

language
protected static string $_language
Résultat string

$_languageFallback protected_oe static_oe property

language fallback
protected static string $_languageFallback
Résultat string

$_languageLabels protected_oe static_oe property

language labels
protected static array $_languageLabels
Résultat array

$_path protected_oe static_oe property

path to language files
protected static string $_path
Résultat string

$_translations protected_oe static_oe property

translation cache
protected static array $_translations
Résultat array