Interface Yiisoft\Translator\TranslatorInterface
| Implemented by | Yiisoft\Translator\Translator |
|---|
Translator translates a message into the specified language.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| addCategorySources() | Add category sources. | Yiisoft\Translator\TranslatorInterface |
| getLocale() | Yiisoft\Translator\TranslatorInterface | |
| setLocale() | Set the default locale. | Yiisoft\Translator\TranslatorInterface |
| translate() | Translates a message into the specified language. | Yiisoft\Translator\TranslatorInterface |
| withDefaultCategory() | Get a new translator instance with category to be used by default in case category isn't specified explicitly. | Yiisoft\Translator\TranslatorInterface |
| withLocale() | Get a new translator instance with locale to be used by default in case locale isn't specified explicitly. | Yiisoft\Translator\TranslatorInterface |
Method Details
Add category sources.
| public abstract $this addCategorySources ( Yiisoft\Translator\CategorySource $categories ) | ||
| $categories | Yiisoft\Translator\CategorySource | |
public function addCategorySources(CategorySource ...$categories): static;
| public abstract string getLocale ( ) | ||
| return | string |
Default locale. |
|---|---|---|
public function getLocale(): string;
Set the default locale.
| public abstract $this setLocale ( string $locale ) | ||
| $locale | string | |
public function setLocale(string $locale): static;
Translates a message into the specified language.
| public abstract string translate ( string|\Stringable $id, array $parameters = [], string|null $category = null, string|null $locale = null ) | ||
| $id | string|\Stringable |
The ID of the message to be translated. It can be either artificial ID or the source message. |
| $parameters | array |
An array of parameters for the message. |
| $category | string|null |
The message category. Null means default category. |
| $locale | string|null |
The target locale. Null means default locale. |
| return | string |
The translated message or source string ID if translation was not found or is not required. |
|---|---|---|
public function translate(
string|Stringable $id,
array $parameters = [],
?string $category = null,
?string $locale = null
): string;
Get a new translator instance with category to be used by default in case category isn't specified explicitly.
| public abstract $this withDefaultCategory ( string $category ) | ||
| $category | string | |
public function withDefaultCategory(string $category): static;
Get a new translator instance with locale to be used by default in case locale isn't specified explicitly.
| public abstract $this withLocale ( string $locale ) | ||
| $locale | string | |
public function withLocale(string $locale): static;
Signup or Login in order to comment.