Final Class Yiisoft\I18n\LocaleProvider
| Inheritance | Yiisoft\I18n\LocaleProvider |
|---|
LocaleProvider is a stateful service that stores current locale.
Other services may use it as a dependency.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| __construct() | Yiisoft\I18n\LocaleProvider | |
| get() | Yiisoft\I18n\LocaleProvider | |
| isDefaultLocale() | Yiisoft\I18n\LocaleProvider | |
| set() | Yiisoft\I18n\LocaleProvider |
Method Details
| public __construct( Yiisoft\I18n\Locale $defaultLocale ): mixed | ||
| $defaultLocale | Yiisoft\I18n\Locale | |
public function __construct(
private Locale $defaultLocale,
) {}
| public get( ): Yiisoft\I18n\Locale |
public function get(): Locale
{
return $this->locale ?? $this->defaultLocale;
}
| public isDefaultLocale( ): boolean |
public function isDefaultLocale(): bool
{
return $this->locale === null || $this->locale->asString() === $this->defaultLocale->asString();
}
| public set( Yiisoft\I18n\Locale $locale ): void | ||
| $locale | Yiisoft\I18n\Locale | |
public function set(Locale $locale): void
{
$this->locale = $locale;
}
Signup or Login in order to comment.