class LocaleResolver (View source)

Resolves the interface language for the current request.

Single source of truth for the locale precedence used by the gettext chain (AppInitializer), the Twig translator (AppManager), and the page chrome (PageRenderer) - they must all agree on the active locale.

Constants

private DEFAULT_LOCALE

Methods

__construct(ConfigurationManager $config, UserContextService $userContext, Request $request)

No description

string
resolve()

Resolves the active locale. Precedence: GET lang override (login page language switcher) > session user language > interface.language config.

array
getSupportedLocales()

Returns the enabled locales from interface.enabled_languages, trimmed and with empty entries dropped.

Details

__construct(ConfigurationManager $config, UserContextService $userContext, Request $request)

No description

Parameters

ConfigurationManager $config
UserContextService $userContext
Request $request

string resolve()

Resolves the active locale. Precedence: GET lang override (login page language switcher) > session user language > interface.language config.

Return Value

string

The resolved locale code

array getSupportedLocales()

Returns the enabled locales from interface.enabled_languages, trimmed and with empty entries dropped.

Return Value

array

The enabled locales; falls back to ['en_EN']