0 follower

Interface Yiisoft\Translator\TranslatorInterface

Implemented byYiisoft\Translator\Translator

Translator translates a message into the specified language.

Public Methods

Hide inherited 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

Hide inherited methods

addCategorySources() public abstract method

Add category sources.

public abstract $this addCategorySources ( Yiisoft\Translator\CategorySource $categories )
$categories Yiisoft\Translator\CategorySource

                public function addCategorySources(CategorySource ...$categories): static;

            
getLocale() public abstract method

public abstract string getLocale ( )
return string

Default locale.

                public function getLocale(): string;

            
setLocale() public abstract method

Set the default locale.

public abstract $this setLocale ( string $locale )
$locale string

                public function setLocale(string $locale): static;

            
translate() public abstract method

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;

            
withDefaultCategory() public abstract method

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;

            
withLocale() public abstract method

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;