You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Move twigL functions into a separate Service class and inject it as app['labels.service'] (or add the functions to the app['labels'] class), then have helper functions exposed:
translate($label, $lang = false) exposed for other extensions to use.
setCurrentLanguage
etc.
Currently, I'm doing the following in my extension:
$labels = $app['labels']->getLabels();
$lang = mb_strtolower($request->query->get('_locale', 'nl'));
$label = $app['labels']->cleanLabel('MUH LABEL');
$result = $label;
if (isset($labels[$label][$lang]) && !empty($labels[$label][$lang])) {
$result = $labels[$label][$lang];
}
elseif ($app['labels.config']->isAddMissing() && empty($labels[$label])) {
$app['labels']->addLabel($label);
}
// replace 'MUH LABEL' with the string you need to translate
// use $result as the translated label
The text was updated successfully, but these errors were encountered:
Move
twigL
functions into a separateService
class and inject it asapp['labels.service']
(or add the functions to theapp['labels']
class), then have helper functions exposed:translate($label, $lang = false)
exposed for other extensions to use.setCurrentLanguage
Currently, I'm doing the following in my extension:
The text was updated successfully, but these errors were encountered: