PHP 클래스 lithium\g11n\Message

1. Marking messages as translatable. $t() and $tn() (implemented in aliases()) are recognized as message marking and picked up by the extraction parser. 2. Extracting marked messages. Messages can be extracted through the g11n command which in turn utilizes the Catalog class with the built-in Code adapter or other custom adapters which are concerned with extracting translatable content. 3. Creating a message template from extracted messages. Templates are created by the g11n command using the Catalog class with an adapter for a format you prefer. 4. Translating messages. The actual translation of messages by translators happens outside using external applications. 5. Storing translated messages. Translations are most often stored by the external applications itself. 6. Retrieving the translation for a message. See description for Message::translate().
또한 보기: lithium\g11n\Catalog
또한 보기: lithium\console\command\G11n
또한 보기: lithium\g11n\catalog\adapter\Code
상속: extends lithium\core\StaticObject
파일 보기 프로젝트 열기: unionofrad/lithium 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$_cachedPages array Holds cached message pages generated and used by lithium\g11n\Message::_translated().

공개 메소드들

메소드 설명
aliases ( ) : array Returns an array containing named closures which are aliases for translate().
cache ( array $cache = null ) : array Returns or sets the page cache used for mapping message ids to translations.
translate ( string $id, array $options = [] ) : string Translates a message according to the current or provided locale and into its correct plural form.

보호된 메소드들

메소드 설명
_translated ( string $id, integer $count, string $locale, array $options = [] ) : string Retrieves translations through the Catalog class by using $id as the lookup key and taking the current or - if specified - the provided locale as well as the scope into account. Hereupon the correct plural form is determined by passing the value of the 'count' option to a closure.

메소드 상세

_translated() 보호된 정적인 메소드

Retrieves translations through the Catalog class by using $id as the lookup key and taking the current or - if specified - the provided locale as well as the scope into account. Hereupon the correct plural form is determined by passing the value of the 'count' option to a closure.
또한 보기: lithium\g11n\Catalog
protected static _translated ( string $id, integer $count, string $locale, array $options = [] ) : string
$id string The lookup key.
$count integer Used to determine the correct plural form.
$locale string The target locale.
$options array Passed through to `Catalog::read()`. Valid options are: - `'scope'`: The scope of the message. - `'context'`: The disambiguating context.
리턴 string The translation or `null` if none could be found or the plural form could not be determined.

aliases() 공개 정적인 메소드

They can be embedded as content filters in the template layer using a filter for Media::_handle() or be used in other places where needed. Usage: $t('bike'); $tn('bike', 'bikes', 3); Using in a method: public function index() { extract(Message::aliases()); $notice = $t('look'); }
또한 보기: lithium\net\http\Media::_handle()
public static aliases ( ) : array
리턴 array Named aliases (`'t'` and `'tn'`) for translation functions.

cache() 공개 정적인 메소드

Returns or sets the page cache used for mapping message ids to translations.
public static cache ( array $cache = null ) : array
$cache array A multidimensional array to use when pre-populating the cache. The structure of the array is `scope/locale/id`. If `false`, the cache is cleared.
리턴 array Returns an array of cached pages, formatted per the description for `$cache`.

translate() 공개 정적인 메소드

Usage: Message::translate('Mind the gap.'); Message::translate('house', array('count' => 23)); String::insert()-style placeholders may be used within the message and replacements provided directly within the options argument. Example: Message::translate('I can see {:count} bike.'); Message::translate('This painting is {:color}.', array( 'color' => Message::translate('silver'), ));
또한 보기: lithium\util\String::insert()
public static translate ( string $id, array $options = [] ) : string
$id string The id to use when looking up the translation.
$options array Valid options are: - `'count'`: Used to determine the correct plural form. You can either pass a signed or unsigned integer, the behavior when passing other types is yet undefined. The count is made absolute before being passed to the pluralization function. This has the effect that that with i.e. an English pluralization function passing `-1` results in a singular translation. - `'locale'`: The target locale, defaults to current locale. - `'scope'`: The scope of the message. - `'context'`: The disambiguating context (optional). - `'default'`: Is used as a fall back if `_translated()` returns without a result. - `'noop'`: If `true` no whatsoever lookup takes place.
리턴 string The translation or the value of the `'default'` option if none could be found.

프로퍼티 상세

$_cachedPages 보호되어 있는 정적으로 프로퍼티

Holds cached message pages generated and used by lithium\g11n\Message::_translated().
또한 보기: lithium\g11n\Message::_translated()
protected static array $_cachedPages
리턴 array