class LocaleCollection (View source)

The LocaleCollection class contains all locales available in current Flow installation, and describes hierarchical relations between them.

This class maintans a hierarchical relation between locales. For example, a locale "en_GB" will be a child of a locale "en".

Properties

protected Locale[] $localeCollection

This array contains all locales added to this collection.

protected Locale[] $localeParentCollection

This array contains a parent Locale objects for given locale.

Methods

bool
addLocale(Locale $locale)

Adds a locale to the collection.

mixed
getParentLocaleOf(Locale $locale)

Returns a parent Locale object of the locale provided.

mixed
findBestMatchingLocale(Locale $locale)

Returns Locale object which represents one of locales installed and which is most similar to the "template" Locale object given as parameter.

Details

bool addLocale(Locale $locale)

Adds a locale to the collection.

Parameters

Locale $locale

The Locale to be inserted

Return Value

bool

false when same locale was already inserted before

mixed getParentLocaleOf(Locale $locale)

Returns a parent Locale object of the locale provided.

The parent is a locale which is more generic than the one given as parameter. For example, the parent for locale en_GB will be locale en, of course if it exists in the locale tree of available locales.

This method returns NULL when no parent locale is available, or when Locale object provided is not in the tree (ie it's not in a group of available locales).

Note: to find a best-matching locale to one which doesn't exist in the system, please use findBestMatchingLocale() method of this class.

Parameters

Locale $locale

The Locale to search parent for

Return Value

mixed

Existing Locale instance or NULL on failure

mixed findBestMatchingLocale(Locale $locale)

Returns Locale object which represents one of locales installed and which is most similar to the "template" Locale object given as parameter.

Parameters

Locale $locale

The "template" locale to be matched

Return Value

mixed

Existing Locale instance on success, NULL on failure