PHP 클래스 yii\i18n\MessageSource

A message source stores message translations in some persistent storage. Child classes should override MessageSource::loadMessages to provide translated messages.
부터: 2.0
저자: Qiang Xue ([email protected])
상속: extends yii\base\Component
파일 보기 프로젝트 열기: yiisoft/yii2 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$forceTranslation whether to force message translation when the source and target languages are the same. Defaults to false, meaning translation is only performed when source and target languages are different.
$sourceLanguage the language that the original messages are in. If not set, it will use the value of [[\yii\base\Application::sourceLanguage]].

공개 메소드들

메소드 설명
init ( ) Initializes this component.
translate ( string $category, string $message, string $language ) : string | boolean Translates a message to the specified language.

보호된 메소드들

메소드 설명
loadMessages ( string $category, string $language ) : array Loads the message translation for the specified language and category.
translateMessage ( string $category, string $message, string $language ) : string | boolean Translates the specified message.

메소드 상세

init() 공개 메소드

Initializes this component.
public init ( )

loadMessages() 보호된 메소드

If translation for specific locale code such as en-US isn't found it tries more generic en.
protected loadMessages ( string $category, string $language ) : array
$category string the message category
$language string the target language
리턴 array the loaded messages. The keys are original messages, and the values are translated messages.

translate() 공개 메소드

Note that unless [[forceTranslation]] is true, if the target language is the same as the [[sourceLanguage|source language]], the message will NOT be translated. If a translation is not found, a [[EVENT_MISSING_TRANSLATION|missingTranslation]] event will be triggered.
public translate ( string $category, string $message, string $language ) : string | boolean
$category string the message category
$message string the message to be translated
$language string the target language
리턴 string | boolean the translated message or false if translation wasn't found or isn't required

translateMessage() 보호된 메소드

If the message is not found, a [[EVENT_MISSING_TRANSLATION|missingTranslation]] event will be triggered. If there is an event handler, it may provide a [[MissingTranslationEvent::$translatedMessage|fallback translation]]. If no fallback translation is provided this method will return false.
protected translateMessage ( string $category, string $message, string $language ) : string | boolean
$category string the category that the message belongs to.
$message string the message to be translated.
$language string the target language.
리턴 string | boolean the translated message or false if translation wasn't found.

프로퍼티 상세

$forceTranslation 공개적으로 프로퍼티

whether to force message translation when the source and target languages are the same. Defaults to false, meaning translation is only performed when source and target languages are different.
public $forceTranslation

$sourceLanguage 공개적으로 프로퍼티

the language that the original messages are in. If not set, it will use the value of [[\yii\base\Application::sourceLanguage]].
public $sourceLanguage