PHP 클래스 Neos\Flow\I18n\Translator

Messages (labels) can be translated in two modes: - by original label: untranslated label is used as a key - by ID: string identifier is used as a key (eg. user.noaccess) Correct plural form of translated message is returned when $quantity parameter is provided to a method. Otherwise, or on failure just translated version is returned (eg. when string is translated only to one form). When all fails, untranslated (original) string or ID is returned (depends on translation method). Placeholders' resolving is done when needed (see FormatResolver class). Actual translating is done by injected TranslationProvider instance, so storage format depends on concrete implementation.
또한 보기: FormatResolver
또한 보기: TranslationProvider\TranslationProviderInterface
또한 보기: Cldr\Reader\PluralsReader
파일 보기 프로젝트 열기: neos/flow-development-collection 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$formatResolver FormatResolver
$localizationService Service
$pluralsReader Neos\Flow\I18n\Cldr\Reader\PluralsReader
$translationProvider Neos\Flow\I18n\TranslationProvider\TranslationProviderInterface

공개 메소드들

메소드 설명
injectFormatResolver ( FormatResolver $formatResolver ) : void
injectLocalizationService ( Service $localizationService ) : void
injectPluralsReader ( PluralsReader $pluralsReader ) : void
injectTranslationProvider ( Neos\Flow\I18n\TranslationProvider\TranslationProviderInterface $translationProvider ) : void
translateById ( string $labelId, array $arguments = [], mixed $quantity = null, Locale $locale = null, string $sourceName = 'Main', string $packageKey = 'Neos.Flow' ) : string Returns translated string found under the $labelId.
translateByOriginalLabel ( string $originalLabel, array $arguments = [], mixed $quantity = null, Locale $locale = null, string $sourceName = 'Main', string $packageKey = 'Neos.Flow' ) : string Translates the message given as $originalLabel.

보호된 메소드들

메소드 설명
getPluralForm ( mixed $quantity, Locale $locale ) : string Get the plural form to be used.

메소드 상세

getPluralForm() 보호된 메소드

If $quantity is numeric and non-NULL, the plural form for provided $locale will be chosen according to it. In all other cases, NULL is returned.
protected getPluralForm ( mixed $quantity, Locale $locale ) : string
$quantity mixed
$locale Locale
리턴 string

injectFormatResolver() 공개 메소드

public injectFormatResolver ( FormatResolver $formatResolver ) : void
$formatResolver FormatResolver
리턴 void

injectLocalizationService() 공개 메소드

public injectLocalizationService ( Service $localizationService ) : void
$localizationService Service
리턴 void

injectPluralsReader() 공개 메소드

public injectPluralsReader ( PluralsReader $pluralsReader ) : void
$pluralsReader Neos\Flow\I18n\Cldr\Reader\PluralsReader
리턴 void

injectTranslationProvider() 공개 메소드

public injectTranslationProvider ( Neos\Flow\I18n\TranslationProvider\TranslationProviderInterface $translationProvider ) : void
$translationProvider Neos\Flow\I18n\TranslationProvider\TranslationProviderInterface
리턴 void

translateById() 공개 메소드

Searches for a translation in the source as defined by $sourceName (interpretation depends on concrete translation provider used). If any arguments are provided in the $arguments array, they will be inserted to the translated string (in place of corresponding placeholders, with format defined by these placeholders). If $quantity is provided, correct plural form for provided $locale will be chosen and used to choose correct translation variant.
또한 보기: Translator::translateByOriginalLabel()
public translateById ( string $labelId, array $arguments = [], mixed $quantity = null, Locale $locale = null, string $sourceName = 'Main', string $packageKey = 'Neos.Flow' ) : string
$labelId string Key to use for finding translation
$arguments array An array of values to replace placeholders with
$quantity mixed A number to find plural form for (float or int), NULL to not use plural forms
$locale Locale Locale to use (NULL for default one)
$sourceName string Name of file with translations, base path is $packageKey/Resources/Private/Locale/Translations/
$packageKey string Key of the package containing the source file
리턴 string Translated message or NULL on failure

translateByOriginalLabel() 공개 메소드

Searches for a translation in the source as defined by $sourceName (interpretation depends on concrete translation provider used). If any arguments are provided in the $arguments array, they will be inserted to the translated string (in place of corresponding placeholders, with format defined by these placeholders). If $quantity is provided, correct plural form for provided $locale will be chosen and used to choose correct translation variant. If no $locale is provided, default system locale will be used.
public translateByOriginalLabel ( string $originalLabel, array $arguments = [], mixed $quantity = null, Locale $locale = null, string $sourceName = 'Main', string $packageKey = 'Neos.Flow' ) : string
$originalLabel string Untranslated message
$arguments array An array of values to replace placeholders with
$quantity mixed A number to find plural form for (float or int), NULL to not use plural forms
$locale Locale Locale to use (NULL for default one)
$sourceName string Name of file with translations, base path is $packageKey/Resources/Private/Locale/Translations/
$packageKey string Key of the package containing the source file
리턴 string Translated $originalLabel or $originalLabel itself on failure

프로퍼티 상세

$formatResolver 보호되어 있는 프로퍼티

protected FormatResolver,Neos\Flow\I18n $formatResolver
리턴 FormatResolver

$localizationService 보호되어 있는 프로퍼티

protected Service,Neos\Flow\I18n $localizationService
리턴 Service

$pluralsReader 보호되어 있는 프로퍼티

protected PluralsReader,Neos\Flow\I18n\Cldr\Reader $pluralsReader
리턴 Neos\Flow\I18n\Cldr\Reader\PluralsReader

$translationProvider 보호되어 있는 프로퍼티

protected TranslationProviderInterface,Neos\Flow\I18n\TranslationProvider $translationProvider
리턴 Neos\Flow\I18n\TranslationProvider\TranslationProviderInterface