PHP 클래스 Habari\Locale

Provides translation services.
파일 보기 프로젝트 열기: habari/system 1 사용 예제들

공개 메소드들

메소드 설명
__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