CoolCMS API

TranslatorInitTrait

Table of Contents

Constants

LOCALE_MAP  : mixed = ['cs' => 'cs_CZ', 'en' => 'en_US', 'sk' => 'sk_...
Maps the short language code to the full locale of the registered NEON sources.

Properties

$translator  : ITranslator
$translatorSessionResolver  : Session
$translatorDomain  : string

Methods

getTranslator()  : ITranslator
handleChangeLocale()  : void
initializeTranslator()  : void
setTranslator()  : $this
setTranslatorDomain()  : void

Constants

LOCALE_MAP

Maps the short language code to the full locale of the registered NEON sources.

private mixed LOCALE_MAP = ['cs' => 'cs_CZ', 'en' => 'en_US', 'sk' => 'sk_SK']

The short code (cs, en, sk) comes from LanguageContext, derived from the URL parameter loc/lang; the full locales are cs_CZ, en_US, sk_SK. translator.neon configures one shared fallback chain [cs_CZ, cs, en_US, en, sk_SK, sk] for all languages, so a short code would always map to cs_CZ first, whatever language is active. A direct match on the full locale bypasses that.

The Contributte LocaleResolvers\Router (the only configured resolver) looks for the route parameter locale, but this application routes under loc, so it always returns null and the translator falls back to default: cs. An explicit setLocale() from here bypasses the resolver, which Translator::getLocale() asks only while no locale has been set explicitly.

Properties

Methods

handleChangeLocale()

public handleChangeLocale(string $locale) : void
Parameters
$locale : string

initializeTranslator()

public initializeTranslator(string|null $alias) : void
Parameters
$alias : string|null

setTranslator()

public setTranslator(ITranslator $translator) : $this
Parameters
$translator : ITranslator
Return values
$this
On this page

Search results