Tiger_Controller_Plugin_LocalePrefix

@api · extends Zend_Controller_Plugin_Abstract

Tiger_Controller_Plugin_LocalePrefix — semantic /xx/ locale URLs + language resolution.

Makes an optional canonical /xx/ prefix work for EVERY route without editing any of them: it resolves the request's language and strips a leading supported- language segment so the existing routes match the rest.

/es/pricing -> routes "/pricing" (Spanish; cookie set to es) /es/billing/invoice -> routes "/billing/invoice" /es -> routes "/" (home, Spanish) /pricing -> routes "/pricing" (language from cookie/browser)

Resolution precedence (first match wins), then the choice is persisted to the locale cookie so it sticks (matches AskLevi):

  1. URL prefix /xx/ explicit for THIS navigation; also updates the cookie
  2. locale cookie the last explicit choice (UI switcher or a prior URL)
  3. browser Accept-Language the first-visit default
  4. configured default tiger.i18n.default, else the first supported language

Languages are LANGUAGE-ONLY (en, es) per Tiger convention. Only a code in the supported list is treated as a prefix, so a content slug like "no"/"it" is never mistaken for a locale. Defines LANG and registers Zend_Locale for the request. The header language switcher (tiger.prefs.js) writes the same locale cookie + localStorage client-side, so the two mechanisms agree.

Methods

__construct()

__construct(array $supported = ['en'], string $default = 'en')

Configure the supported languages and the fallback language.

  • $supported array — supported language codes (language-only)
  • $default string — fallback language when none resolves

routeStartup()

routeStartup(Zend_Controller_Request_Abstract $request)

Resolve the request language and strip a leading /xx/ prefix so the routes match.

  • $request Zend_Controller_Request_Abstract — the current request