UiTextsLatteExtension
extends Extension
in package
Provides texts for JavaScript templates: a whole translation subtree in one call.
Front end JS components (select-box, lightbox, dropzone, toast) build their DOM themselves.
The front end has many templates, each with its own layout copy, so listing data-*
attributes per text would mean editing every template. Instead a template asks for a subtree
and gets all its keys:
<script type="application/json" id="front-ui-i18n">{uiTexts('front.general.ui')}</script>
The result is a flat array relative.key => translated text (e.g. selectBox.clear) read by
the JS helper assets/js/components/i18n.js through t(key, params).
NOTE: the key list comes from the default locale catalogue (cs is the source of truth), the translation from the current one. A key missing in en/sk is translated by fallback and shows up as missing in the Tracy panel instead of vanishing silently.
NOTE: parameters keep the %name% form (Symfony notation); JS substitutes them.
Table of Contents
Properties
- $translator : Translator
Methods
- __construct() : mixed
- getFunctions() : array<string|int, mixed>
- uiTexts() : array<string, string>
Properties
$translator read-only
private
Translator
$translator
Methods
__construct()
public
__construct(Translator $translator) : mixed
Parameters
- $translator : Translator
getFunctions()
public
getFunctions() : array<string|int, mixed>
Return values
array<string|int, mixed>uiTexts()
public
uiTexts(string $prefix) : array<string, string>
Parameters
- $prefix : string
-
full message id of the subtree, e.g.
front.general.ui(first segment is the domain)