Final Class Yiisoft\Yii\DataView\DefaultTranslatorFactory
| Inheritance | Yiisoft\ |
|---|
Creates the translator used by widgets when none is passed explicitly.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| create() | Yiisoft\ |
Method Details
| public static \ | ||
| $category | string |
A name for {@see \ |
| return | \ |
Translator instance used for translations of messages. |
|---|---|---|
public static function create(string $category): TranslatorInterface
{
$categorySource = new CategorySource(
$category,
new IdMessageReader(),
extension_loaded('intl') ? new IntlMessageFormatter() : new SimpleMessageFormatter(),
);
$translator = new Translator();
$translator->addCategorySources($categorySource);
return $translator;
}
User Contributed Notes
Leave a comment
Join the conversation to share a note.