Civil Date PHP Package

LocaleRegistry
in package

FinalYes

Stores locale definitions used by parsing and formatting APIs.

Built-in locales are registered on first use. Applications may register custom locales and may change the default locale used when no locale option is supplied.

Table of Contents

Methods

all()  : array<string, Locale>
Returns all registered locale definitions.
default()  : Locale
Returns the default locale definition.
find()  : Locale|null
Returns a registered locale.
register()  : void
Registers or replaces a locale definition.
setDefault()  : void
Sets the default locale.

Methods

all()

Returns all registered locale definitions.

public static all() : array<string, Locale>
Return values
array<string, Locale>

Registered locales indexed by language tag.

default()

Returns the default locale definition.

public static default() : Locale
Return values
Locale

Default locale definition.

find()

Returns a registered locale.

public static find(string $languageTag[, bool $fallbackToLanguage = true ]) : Locale|null

When fallback is enabled, a missing regional tag such as fa-IR may resolve to its language-only locale, such as fa.

Parameters
$languageTag : string

Locale language tag.

$fallbackToLanguage : bool = true

Whether a missing language-region tag may resolve to its registered language-only locale.

Return values
Locale|null

Locale definition or null if not found.

register()

Registers or replaces a locale definition.

public static register(Locale $locale) : void
Parameters
$locale : Locale

Locale definition.

setDefault()

Sets the default locale.

public static setDefault(Locale|string $locale) : void

Passing a Locale instance registers it before making it the default.

Parameters
$locale : Locale|string

Locale language tag or definition.

Tags
throws
InvalidArgumentException

If the locale language tag is not registered.

On this page

Search results