class Configuration (View source)

A Configuration instance represents settings to be used with the I18n functionality. Examples of such settings are the locale to be used and overrides for message catalogs.

Properties

protected Locale $defaultLocale
protected Locale $currentLocale
protected array $fallbackRule

Methods

__construct(string $defaultLocaleIdentifier)

Constructs a new configuration object with the given locale identifier to be used as the default locale of this configuration.

getDefaultLocale()

Returns the default locale of this configuration.

void
setCurrentLocale(Locale $locale)

Sets the current locale of this configuration.

getCurrentLocale()

Returns the current locale. This is the default locale if no current locale has been set or the set current locale has a language code of "mul".

setFallbackRule(array $fallbackRule)

Allows to set a fallback order for locale resolving. If not set, the implicit inheritance of locales will be used. That is, if a locale of en_UK is requested, matches will be searched for in en_UK and en before trying the default locale configured in Flow.

array
getFallbackRule()

Returns the current fallback rule.

Details

__construct(string $defaultLocaleIdentifier)

Constructs a new configuration object with the given locale identifier to be used as the default locale of this configuration.

Parameters

string $defaultLocaleIdentifier

Exceptions

InvalidLocaleIdentifierException

Locale getDefaultLocale()

Returns the default locale of this configuration.

Return Value

Locale

void setCurrentLocale(Locale $locale)

Sets the current locale of this configuration.

Parameters

Locale $locale

Return Value

void

Locale getCurrentLocale()

Returns the current locale. This is the default locale if no current locale has been set or the set current locale has a language code of "mul".

Return Value

Locale

setFallbackRule(array $fallbackRule)

Allows to set a fallback order for locale resolving. If not set, the implicit inheritance of locales will be used. That is, if a locale of en_UK is requested, matches will be searched for in en_UK and en before trying the default locale configured in Flow.

If this is given an order of [dk, za, fr_CA] a request for en_UK will be looked up in en_UK, en, dk, za, fr_CA, fr before trying the default locale.

If strict flag is given in the array, the above example would instead look in en_UK, dk, za, fr_CA before trying the default locale. In other words, the implicit fallback is not applied to the locales in the fallback rule.

Here is an example: array('strict' => false, 'order' => array('dk', 'za'))

Parameters

array $fallbackRule

array getFallbackRule()

Returns the current fallback rule.

Return Value

array

See also

setFallbackRule()