PHP Класс I18n

This file is part of AgenDAV. AgenDAV is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or any later version. AgenDAV is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with AgenDAV. If not, see .
Наследование: extends CI_Model
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$category string Current category of translation
$defaultDomain string Default domain of translation
$domain string Current domain of translation
$l10n L10n Instance of the L10n class for localization

Защищенные свойства (Protected)

Свойство Тип Описание
$_categories array Translation categories
$_domains array Translation strings for a specific domain read from the .mo or .po files
$_escape string Escape string
$_lang string Current language used for translations
$_noLocale boolean If a translation file is found it is set to false again

Открытые методы

Метод Описание
__construct ( ) Constructor, use I18n::getInstance() to get the i18n translation object.
clear ( ) : void Clears the domains internal data array. Useful for testing i18n.
domains ( ) : array Get the loaded domains cache.
getInstance ( ) : I18n Return a static instance of the I18n class
insertArgs ( string $translated, array $args ) : string Puts the parameters in raw translated strings
loadLocaleDefinition ( string $filename ) : mixed Parses a locale definition file following the POSIX standard
loadMo ( string $filename ) : mixed Loads the binary .mo file and returns array of translations
loadPo ( string $filename ) : mixed Loads the text .po file and returns array of translations
translate ( string $singular, string $plural = null, string $domain = null, string $category = self::LC_MESSAGES, integer $count = null, string $language = null, string $context = null ) : string Used by the translation functions in basics.php Returns a translated string based on current language and translation files stored in locale folder

Защищенные методы

Метод Описание
_bindTextDomain ( string $domain ) : string Binds the given domain to a file in the specified directory.
_parseLiteralValue ( string $string ) : string Auxiliary function to parse a symbol from a locale definition file
_pluralGuess ( string $header, integer $n ) : integer Attempts to find the plural form of a string.
_translateTime ( string $format, string $domain ) : mixed Returns a Time format definition from corresponding domain

Описание методов

__construct() публичный Метод

Constructor, use I18n::getInstance() to get the i18n translation object.
public __construct ( )

_bindTextDomain() защищенный Метод

Binds the given domain to a file in the specified directory.
protected _bindTextDomain ( string $domain ) : string
$domain string Domain to bind
Результат string Domain binded

_parseLiteralValue() защищенный Метод

Auxiliary function to parse a symbol from a locale definition file
protected _parseLiteralValue ( string $string ) : string
$string string Symbol to be parsed
Результат string parsed symbol

_pluralGuess() защищенный Метод

Attempts to find the plural form of a string.
protected _pluralGuess ( string $header, integer $n ) : integer
$header string Type
$n integer Number
Результат integer plural match

_translateTime() защищенный Метод

Returns a Time format definition from corresponding domain
protected _translateTime ( string $format, string $domain ) : mixed
$format string Format to be translated
$domain string Domain where format is stored
Результат mixed translated format string if only value or array of translated strings for corresponding format.

clear() публичный статический Метод

Clears the domains internal data array. Useful for testing i18n.
public static clear ( ) : void
Результат void

domains() публичный статический Метод

Get the loaded domains cache.
public static domains ( ) : array
Результат array

getInstance() публичный статический Метод

Return a static instance of the I18n class
public static getInstance ( ) : I18n
Результат I18n

insertArgs() публичный статический Метод

Puts the parameters in raw translated strings
public static insertArgs ( string $translated, array $args ) : string
$translated string The raw translated string
$args array The arguments to put in the translation
Результат string Translated string with arguments

loadLocaleDefinition() публичный статический Метод

Parses a locale definition file following the POSIX standard
public static loadLocaleDefinition ( string $filename ) : mixed
$filename string Locale definition filename
Результат mixed Array of definitions on success or false on failure

loadMo() публичный статический Метод

Loads the binary .mo file and returns array of translations
public static loadMo ( string $filename ) : mixed
$filename string Binary .mo file to load
Результат mixed Array of translations on success or false on failure

loadPo() публичный статический Метод

Loads the text .po file and returns array of translations
public static loadPo ( string $filename ) : mixed
$filename string Text .po file to load
Результат mixed Array of translations on success or false on failure

translate() публичный статический Метод

Used by the translation functions in basics.php Returns a translated string based on current language and translation files stored in locale folder
public static translate ( string $singular, string $plural = null, string $domain = null, string $category = self::LC_MESSAGES, integer $count = null, string $language = null, string $context = null ) : string
$singular string String to translate
$plural string Plural string (if any)
$domain string Domain The domain of the translation. Domains are often used by plugin translations. If null, the default domain will be used.
$category string Category The integer value of the category to use.
$count integer Count Count is used with $plural to choose the correct plural form.
$language string Language to translate string to. If null it checks for language in session followed by Config.language configuration variable.
$context string Context The context of the translation, e.g a verb or a noun.
Результат string translated string.

Описание свойств

$_categories защищенное свойство

Translation categories
protected array $_categories
Результат array

$_domains защищенное свойство

Translation strings for a specific domain read from the .mo or .po files
protected array $_domains
Результат array

$_escape защищенное свойство

Escape string
protected string $_escape
Результат string

$_lang защищенное свойство

Current language used for translations
protected string $_lang
Результат string

$_noLocale защищенное свойство

If a translation file is found it is set to false again
protected bool $_noLocale
Результат boolean

$category публичное свойство

Current category of translation
public string $category
Результат string

$defaultDomain публичное статическое свойство

Default domain of translation
public static string $defaultDomain
Результат string

$domain публичное свойство

Current domain of translation
public string $domain
Результат string

$l10n публичное свойство

Instance of the L10n class for localization
public L10n $l10n
Результат L10n