0 follower

Final Class Yiisoft\I18n\LocaleProvider

InheritanceYiisoft\I18n\LocaleProvider

LocaleProvider is a stateful service that stores current locale.

Other services may use it as a dependency.

Method Details

Hide inherited methods

__construct() public method

public __construct( Yiisoft\I18n\Locale $defaultLocale ): mixed
$defaultLocale Yiisoft\I18n\Locale

                public function __construct(
    private Locale $defaultLocale,
) {}

            
get() public method

public get( ): Yiisoft\I18n\Locale

                public function get(): Locale
{
    return $this->locale ?? $this->defaultLocale;
}

            
isDefaultLocale() public method

public isDefaultLocale( ): boolean

                public function isDefaultLocale(): bool
{
    return $this->locale === null || $this->locale->asString() === $this->defaultLocale->asString();
}

            
set() public method

public set( Yiisoft\I18n\Locale $locale ): void
$locale Yiisoft\I18n\Locale

                public function set(Locale $locale): void
{
    $this->locale = $locale;
}