{"$schema":"https://yii2-framework.github.io/docs/reference/reference.schema.json","schemaVersion":1,"package":"localeurls","title":"Locale URLs","repository":"https://github.com/yii2-extensions/localeurls","ref":"main","commit":"617d5f28c92ad635a70af864d1f67bcf6d278805","generatedAt":"2026-10-18","url":"https://yii2-framework.github.io/docs/extensions/localeurls/reference/","types":{"yii2\\extensions\\localeurls\\LanguageChangedEvent":{"kind":"class","url":"https://yii2-framework.github.io/docs/extensions/localeurls/reference/languagechangedevent/","summary":"Represents the `yii2\\extensions\\localeurls\\UrlLanguageManager::EVENT_LANGUAGE_CHANGED` event, raised when a language from the URL differs from the persisted one.","extends":"yii\\base\\Event","implements":["yii\\base\\Configurable"],"properties":{"language":{"type":"string","default":"''","description":"Language code being persisted, for example `de-AT`."},"oldLanguage":{"type":"string|null","default":"null","description":"Previously persisted language code, or `null` if no language was persisted."}},"inherited":{"properties":{"data":"yii\\base\\Event","handled":"yii\\base\\Event","name":"yii\\base\\Event","sender":"yii\\base\\Event"},"methods":{"__call":"yii\\base\\BaseObject","__construct":"yii\\base\\BaseObject","__get":"yii\\base\\BaseObject","__isset":"yii\\base\\BaseObject","__set":"yii\\base\\BaseObject","__unset":"yii\\base\\BaseObject","canGetProperty":"yii\\base\\BaseObject","canSetProperty":"yii\\base\\BaseObject","className":"yii\\base\\BaseObject","hasHandlers":"yii\\base\\Event","hasMethod":"yii\\base\\BaseObject","hasProperty":"yii\\base\\BaseObject","init":"yii\\base\\BaseObject","off":"yii\\base\\Event","offAll":"yii\\base\\Event","on":"yii\\base\\Event","trigger":"yii\\base\\Event"}}},"yii2\\extensions\\localeurls\\UrlLanguageManager":{"kind":"class","url":"https://yii2-framework.github.io/docs/extensions/localeurls/reference/urllanguagemanager/","summary":"Resolves the application language from a URL code, the persisted choice, the browser, or GeoIP, and adds the language code to created URLs.","extends":"yii\\web\\UrlManager","implements":["yii\\base\\Configurable"],"properties":{"_defaultLanguage":{"type":"string","default":"''","description":"Default language resolved by `init()` from `$defaultLanguage` or the application language.","visibility":"protected"},"defaultLanguage":{"type":"string|null","default":"null","description":"Default language: the language of URLs without a code when `$enableDefaultLanguageUrlCode` is `false`."},"enableDefaultLanguageUrlCode":{"type":"bool","default":"false","description":"Whether the default language uses a URL code like any other language."},"enableLanguageDetection":{"type":"bool","default":"true","description":"Whether to detect the language from the `Accept-Language` header when the URL has no code and no language is persisted."},"enableLanguagePersistence":{"type":"bool","default":"true","description":"Whether to persist the language from the URL in the session and the language cookie."},"enableLocaleUrls":{"type":"bool","default":"true","description":"Whether to enable language processing; when `false`, the manager behaves like `yii\\web\\UrlManager`."},"enablePrettyUrl":{"default":"true","description":"Whether to enable pretty URLs; must be `true` while locale URLs are enabled."},"geoIpLanguageCountries":{"type":"array","default":"[]","description":"GeoIP country codes indexed by the language they select."},"geoIpServerVar":{"type":"string","default":"'HTTP_X_GEO_COUNTRY'","description":"Name of the server variable that carries the GeoIP country code."},"ignoreLanguageUrlPatterns":{"type":"array","default":"[]","description":"Regular expressions that exclude routes and URLs from language processing."},"keepUppercaseLanguageCode":{"type":"bool","default":"false","description":"Whether to keep uppercase letters of language codes in URLs."},"languageCookieDuration":{"type":"int","default":"2592000","description":"Lifetime of the language cookie in seconds; `0` disables the cookie."},"languageCookieName":{"type":"string","default":"'_language'","description":"Name of the language cookie."},"languageCookieOptions":{"type":"array","default":"[]","description":"Additional `yii\\web\\Cookie` properties for the language cookie."},"languageParam":{"type":"string","default":"'language'","description":"Name of the `createUrl()` parameter that selects the language of the created URL."},"languageRedirectCode":{"type":"int","default":"302","description":"HTTP status code of language redirects."},"languages":{"type":"array","default":"[]","description":"Available languages: codes (`en-US`), wildcards (`es-*`), or URL aliases mapped to codes (`'english' => 'en'`)."},"languageSessionKey":{"type":"string|bool","default":"'_language'","description":"Session key that stores the language; `false` disables session persistence."}},"methods":{"createUrl":{"signature":"public function createUrl(array|string $params): string","summary":"Creates a URL and inserts the language code after the base URL or the script name.","params":[{"name":"$params","type":"array|string","description":"Route and parameters; `$languageParam` selects the language of the URL."}],"return":{"type":"string","description":"Created URL."},"throws":[{"type":"yii\\base\\InvalidConfigException","description":"if the base URL or the script URL cannot be determined."}]},"detectLanguage":{"signature":"protected function detectLanguage(yii\\web\\Request $request): string|null","summary":"Detects the language from the `Accept-Language` header, then from the GeoIP country.","params":[{"name":"$request","type":"yii\\web\\Request","description":"Request that provides the header and the GeoIP country."}],"return":{"type":"string|null","description":"Detected language code, or `null` if no configured language matches."},"visibility":"protected"},"getDefaultLanguage":{"signature":"public function getDefaultLanguage(): string","summary":"Returns the default language: `$defaultLanguage`, or the application language captured when the manager was initialized.","return":{"type":"string","description":"Default language code, for example `en`."}},"init":{"signature":"public function init(): void","summary":"Captures the default language and validates the configuration.","return":{"type":"void"},"throws":[{"type":"yii\\base\\InvalidConfigException","description":"if locale URLs are enabled while `$enablePrettyUrl` is `false`, or if the parent configuration is invalid."}]},"loadPersistedLanguage":{"signature":"protected function loadPersistedLanguage(yii\\web\\Request $request): string|null","summary":"Returns the language persisted in the session or, failing that, in the language cookie.","params":[{"name":"$request","type":"yii\\web\\Request","description":"Request that provides the language cookie."}],"return":{"type":"string|null","description":"Persisted language code, or `null` if none is stored."},"visibility":"protected"},"matchCode":{"signature":"protected function matchCode(string $code): array","summary":"Matches a language code against `$languages`, case-insensitively and including wildcards.","params":[{"name":"$code","type":"string","description":"Language code to match, for example `en`, `en-US`, or `es-MX`."}],"return":{"type":"array","description":"Matched language and country, or `[null, null]` if no configured language matches."},"visibility":"protected"},"parseRequest":{"signature":"public function parseRequest(yii\\web\\Request $request): array|bool","summary":"Resolves the request language, removes its code from the path info, and parses the request.","params":[{"name":"$request","type":"yii\\web\\Request","description":"Request to parse."}],"return":{"type":"array|bool","description":"Route and parameters, or `false` if no rule matches the request."},"throws":[{"type":"yii\\base\\InvalidConfigException","description":"if the path info of the request cannot be determined."},{"type":"yii\\web\\NotFoundHttpException","description":"if no rule matches the request while a language redirect is pending, or if the URL normalizer action is `ACTION_NOT_FOUND` and the path info is not normalized."},{"type":"yii\\web\\UrlNormalizerRedirectException","description":"if the request must be redirected."}]},"persistLanguage":{"signature":"protected function persistLanguage(yii\\web\\Request $request, string $language): void","summary":"Stores the language in the session and the language cookie.","params":[{"name":"$request","type":"yii\\web\\Request","description":"Request that provides the previously persisted language."},{"name":"$language","type":"string","description":"Language code to persist, for example `en` or `de-AT`."}],"return":{"type":"void"},"visibility":"protected"},"processLocaleUrl":{"signature":"protected function processLocaleUrl(yii\\web\\Request $request): string|null","summary":"Resolves the language of the request and returns the language redirect it requires.","params":[{"name":"$request","type":"yii\\web\\Request","description":"Request whose path info is processed."}],"return":{"type":"string|null","description":"Language code or alias to redirect to, `''` to redirect to the URL without a language code, or `null` if no language redirect is required."},"throws":[{"type":"yii\\base\\InvalidConfigException","description":"if the path info of the request cannot be determined."}],"visibility":"protected"}},"events":{"EVENT_LANGUAGE_CHANGED":{"value":"'languageChanged'","type":"yii2\\extensions\\localeurls\\LanguageChangedEvent","description":"Raised before a language from the URL that differs from the persisted one is persisted."}},"inherited":{"properties":{"baseUrl":"yii\\web\\UrlManager","behaviors":"yii\\base\\Component","cache":"yii\\web\\UrlManager","cacheKey":"yii\\web\\UrlManager","enableStrictParsing":"yii\\web\\UrlManager","hostInfo":"yii\\web\\UrlManager","normalizer":"yii\\web\\UrlManager","routeParam":"yii\\web\\UrlManager","ruleConfig":"yii\\web\\UrlManager","rules":"yii\\web\\UrlManager","scriptUrl":"yii\\web\\UrlManager","showScriptName":"yii\\web\\UrlManager","suffix":"yii\\web\\UrlManager"},"methods":{"__call":"yii\\base\\Component","__clone":"yii\\base\\Component","__construct":"yii\\base\\BaseObject","__get":"yii\\base\\Component","__isset":"yii\\base\\Component","__set":"yii\\base\\Component","__unset":"yii\\base\\Component","addRules":"yii\\web\\UrlManager","attachBehavior":"yii\\base\\Component","attachBehaviors":"yii\\base\\Component","behaviors":"yii\\base\\Component","buildRules":"yii\\web\\UrlManager","canBeCached":"yii\\web\\UrlManager","canGetProperty":"yii\\base\\Component","canSetProperty":"yii\\base\\Component","className":"yii\\base\\BaseObject","createAbsoluteUrl":"yii\\web\\UrlManager","detachBehavior":"yii\\base\\Component","detachBehaviors":"yii\\base\\Component","ensureBehaviors":"yii\\base\\Component","getBaseUrl":"yii\\web\\UrlManager","getBehavior":"yii\\base\\Component","getBehaviors":"yii\\base\\Component","getBuiltRulesFromCache":"yii\\web\\UrlManager","getHostInfo":"yii\\web\\UrlManager","getScriptUrl":"yii\\web\\UrlManager","getUrlFromCache":"yii\\web\\UrlManager","hasEventHandlers":"yii\\base\\Component","hasMethod":"yii\\base\\Component","hasProperty":"yii\\base\\Component","off":"yii\\base\\Component","on":"yii\\base\\Component","setBaseUrl":"yii\\web\\UrlManager","setBuiltRulesCache":"yii\\web\\UrlManager","setHostInfo":"yii\\web\\UrlManager","setRuleToCache":"yii\\web\\UrlManager","setScriptUrl":"yii\\web\\UrlManager","trigger":"yii\\base\\Component"}}}}}
