PHP Класс Habari\Locale

Provides translation services.
Показать файл Открыть проект Примеры использования класса

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

Метод Описание
__run_loadfile_test ( $filename ) DO NOT USE THIS FUNCTION.
__run_plural_test ( $header ) DO NOT USE THIS FUNCTION.
_e ( ) Echo a version of the string translated into the current locale
_n ( string $singular, string $plural, string $count, string $domain = 'habari' ) : string Return a singular or plural string translated into the current locale based on the count provided
_ne ( string $singular, string $plural, string $count, string $domain = 'habari' ) Echo singular or plural version of the string, translated into the current locale, based on the count provided
_t ( string $text, array $args = [], string $domain = 'habari' ) : string Return a version of the string translated into the current locale
_u ( string $text, string $domain = 'habari' ) : string Given a string translated into the current locale, return the untranslated string.
get ( ) : string Return the current locale
get_messages ( string $domain = 'habari' ) : array Return the entire message catalog for a domain as an array
list_all ( ) : array. function list_all Retrieves an array of the Habari locales that are installed
load_pluggable_domain ( string $domain, string $base_dir ) : boolean Load translations for a given domain and base directory for a pluggable object.
set ( string $locale = null ) Sets the locale for Habari.
set_system_locale ( ) : string Set system locale.
translate_xml ( SimpleXMLElement $parent, SimpleXMLElement $child, string $ns = 'http://www.w3.org/XML/1998/namespace', null | string $locale = null ) Return a translated value of a SimpleXml object value based on the locale and namespace

Приватные методы

Метод Описание
get_plural_function ( $header )
load_domain ( string $domain ) : boolean Load translations for a given domain.
load_file ( string $domain, string $file ) : boolean Load translations from a given file.

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

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

This function is only to be used by the test case for the Locale class!
public static __run_loadfile_test ( $filename )

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

This function is only to be used by the test case for the Locale class!
public static __run_plural_test ( $header )

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

Echo a version of the string translated into the current locale
public static _e ( )

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

Return a singular or plural string translated into the current locale based on the count provided
public static _n ( string $singular, string $plural, string $count, string $domain = 'habari' ) : string
$singular string The singular form
$plural string The plural form
$count string The count
$domain string (optional) The domain to search for the message
Результат string The appropriately translated string

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

Echo singular or plural version of the string, translated into the current locale, based on the count provided
public static _ne ( string $singular, string $plural, string $count, string $domain = 'habari' )
$singular string The singular form
$plural string The plural form
$count string The count
$domain string (optional) The domain to search for the message

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

Return a version of the string translated into the current locale
public static _t ( string $text, array $args = [], string $domain = 'habari' ) : string
$text string The text to echo translated
$args array
$domain string (optional) The domain to search for the message
Результат string The translated string

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

Given a string translated into the current locale, return the untranslated string.
public static _u ( string $text, string $domain = 'habari' ) : string
$text string The translated string
$domain string (optional) The domain to search for the message
Результат string The untranslated string

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

Return the current locale
public static get ( ) : string
Результат string The current locale.

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

Return the entire message catalog for a domain as an array
public static get_messages ( string $domain = 'habari' ) : array
$domain string (optional) The domain to return
Результат array The array of locale messages

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

function list_all Retrieves an array of the Habari locales that are installed
public static list_all ( ) : array.
Результат array.

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

Translations are stored in gettext-style .mo files. The internal workings of the file format are not entirely meant to be understood.
public static load_pluggable_domain ( string $domain, string $base_dir ) : boolean
$domain string the domain to load
$base_dir string the base directory in which to find the translation files
Результат boolean true if data was successfully loaded, false otherwise

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

Sets the locale for Habari.
public static set ( string $locale = null )
$locale string A language code like 'en' or 'en-us' or 'x-klingon', will be lowercased

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

The problem is that every platform has its own way to designate a locale, so for German you could have 'de', 'de_DE', 'de_DE.UTF-8', 'de_DE.UTF-8@euro' (Linux) or 'DEU' (Windows), etc.
public static set_system_locale ( ) : string
Результат string the locale that was picked, or false if an error occurred

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

Return a translated value of a SimpleXml object value based on the locale and namespace
public static translate_xml ( SimpleXMLElement $parent, SimpleXMLElement $child, string $ns = 'http://www.w3.org/XML/1998/namespace', null | string $locale = null )
$parent SimpleXMLElement The parent node of the node we are translating
$child SimpleXMLElement The child node we're trying to translate
$ns string The namespace to use for the lang attribute of the node to be translated
$locale null | string The locale we want to translate into