class Detector (View source)

The Detector class provides methods for automatic locale detection

Properties

protected Service $localizationService
protected LocaleCollection $localeCollection

A collection of Locale objects representing currently installed locales, in a hierarchical manner.

Methods

void
injectLocalizationService(Service $localizationService)

No description

void
injectLocaleCollection(LocaleCollection $localeCollection)

No description

detectLocaleFromHttpHeader(string $acceptLanguageHeader)

Returns best-matching Locale object based on the Accept-Language header provided as parameter. System default locale will be returned if no successful matches were done.

detectLocaleFromLocaleTag(string $localeIdentifier)

Returns best-matching Locale object based on the locale identifier provided as parameter. System default locale will be returned if no successful matches were done.

detectLocaleFromTemplateLocale(Locale $locale)

Returns best-matching Locale object based on the template Locale object provided as parameter. System default locale will be returned if no successful matches were done.

Details

void injectLocalizationService(Service $localizationService)

No description

Parameters

Service $localizationService

Return Value

void

void injectLocaleCollection(LocaleCollection $localeCollection)

No description

Parameters

LocaleCollection $localeCollection

Return Value

void

Locale detectLocaleFromHttpHeader(string $acceptLanguageHeader)

Returns best-matching Locale object based on the Accept-Language header provided as parameter. System default locale will be returned if no successful matches were done.

Parameters

string $acceptLanguageHeader

The Accept-Language HTTP header

Return Value

Locale

Best-matching existing Locale instance

Locale detectLocaleFromLocaleTag(string $localeIdentifier)

Returns best-matching Locale object based on the locale identifier provided as parameter. System default locale will be returned if no successful matches were done.

Parameters

string $localeIdentifier

The locale identifier as used in Locale class

Return Value

Locale

Best-matching existing Locale instance

Locale detectLocaleFromTemplateLocale(Locale $locale)

Returns best-matching Locale object based on the template Locale object provided as parameter. System default locale will be returned if no successful matches were done.

Parameters

Locale $locale

The template Locale object

Return Value

Locale

Best-matching existing Locale instance