PHP Class Arcanedev\Localization\Utilities\LocalesManager

Author: ARCANEDEV ([email protected])
Inheritance: implements Arcanedev\Localization\Contracts\LocalesManagerInterface
Mostra file Open project: arcanedev/localization

Protected Properties

Property Type Description
$currentLocale string Current locale.
$defaultLocale string Default locale.
$locales Arcanedev\Localization\Entities\LocaleCollection
$supportedLocales Arcanedev\Localization\Entities\LocaleCollection

Public Methods

Method Description
__construct ( Illuminate\Foundation\Application $app ) Create LocaleManager instance.
getAllLocales ( ) : Arcanedev\Localization\Entities\LocaleCollection Get all locales.
getCurrentLocale ( ) : string Returns current language.
getCurrentLocaleEntity ( ) : Arcanedev\Localization\Entities\Locale Get the current locale entity.
getCurrentOrDefaultLocale ( ) : string Get current or default locale.
getDefaultLocale ( ) : string Get the default locale.
getSupportedLocales ( ) : Arcanedev\Localization\Entities\LocaleCollection Get supported locales.
getSupportedLocalesKeys ( ) : array Get supported locales keys.
isDefaultLocaleHiddenInUrl ( ) : boolean Hide the default locale in URL ??
isDefaultLocaleSupported ( $defaultLocale ) Check if default is supported.
isSupportedLocale ( string $locale ) : boolean Check if locale is supported.
setCurrentLocale ( string $currentLocale ) : self Set the current locale.
setDefaultLocale ( string $defaultLocale = null ) : self Set the default locale.
setLocale ( string | null $locale = null ) : string Set and return current locale.
setSupportedLocales ( array $supportedLocales ) : self Set supported locales.

Private Methods

Method Description
config ( ) : Illuminate\Config\Repository Get config repository.
filterLocales ( array $supportedLocales ) : Arcanedev\Localization\Entities\LocaleCollection Filter locale collection.
getConfig ( string $name, mixed $default = null ) : mixed Get localization config.
load ( ) Load all locales data.
negotiateLocale ( ) : string Get negotiated locale.
request ( ) : Illuminate\Http\Request Get config repository.
updateRegional ( ) Update locale regional.
useAcceptLanguageHeader ( ) : boolean Returns the translation key for a given path.

Method Details

__construct() public method

Create LocaleManager instance.
public __construct ( Illuminate\Foundation\Application $app )
$app Illuminate\Foundation\Application

getAllLocales() public method

Get all locales.
public getAllLocales ( ) : Arcanedev\Localization\Entities\LocaleCollection
return Arcanedev\Localization\Entities\LocaleCollection

getCurrentLocale() public method

Returns current language.
public getCurrentLocale ( ) : string
return string

getCurrentLocaleEntity() public method

Get the current locale entity.
public getCurrentLocaleEntity ( ) : Arcanedev\Localization\Entities\Locale
return Arcanedev\Localization\Entities\Locale

getCurrentOrDefaultLocale() public method

Get current or default locale.

getDefaultLocale() public method

Get the default locale.
public getDefaultLocale ( ) : string
return string

getSupportedLocales() public method

Get supported locales.
public getSupportedLocales ( ) : Arcanedev\Localization\Entities\LocaleCollection
return Arcanedev\Localization\Entities\LocaleCollection

getSupportedLocalesKeys() public method

Get supported locales keys.
public getSupportedLocalesKeys ( ) : array
return array

isDefaultLocaleHiddenInUrl() public method

Hide the default locale in URL ??

isDefaultLocaleSupported() public method

Check if default is supported.
public isDefaultLocaleSupported ( $defaultLocale )

isSupportedLocale() public method

Check if locale is supported.
public isSupportedLocale ( string $locale ) : boolean
$locale string
return boolean

setCurrentLocale() public method

Set the current locale.
public setCurrentLocale ( string $currentLocale ) : self
$currentLocale string
return self

setDefaultLocale() public method

Set the default locale.
public setDefaultLocale ( string $defaultLocale = null ) : self
$defaultLocale string
return self

setLocale() public method

Set and return current locale.
public setLocale ( string | null $locale = null ) : string
$locale string | null
return string

setSupportedLocales() public method

Set supported locales.
public setSupportedLocales ( array $supportedLocales ) : self
$supportedLocales array
return self

Property Details

$currentLocale protected_oe property

Current locale.
protected string $currentLocale
return string

$defaultLocale protected_oe property

Default locale.
protected string $defaultLocale
return string

$locales protected_oe property

protected LocaleCollection,Arcanedev\Localization\Entities $locales
return Arcanedev\Localization\Entities\LocaleCollection

$supportedLocales protected_oe property

protected LocaleCollection,Arcanedev\Localization\Entities $supportedLocales
return Arcanedev\Localization\Entities\LocaleCollection