Frontend Translations

Textual translations are handled by the Glossary-module. You can use the GlossaryFacade in Zed to add entries to Glossary (or you can use the Zed UI).

class GlossaryFacade extends AbstractFacade
    public function createTranslation($keyName, LocaleTransfer $locale, $value, $isActive = true){ ... }
    // there are several other methods in this facade

An entry in the glossary has a key and translations per locale, like this:

['say.hello' => [
    'de_DE => 'Hallo', 
    'en_US' => 'Hello']


Before it can be used in Yves, this data must be exported to the KV-storage. You can use the Redis Desktop Manager to have a look inside and see the values.

Glossary KV and DB

Usage in Twig templates

The translation function is provided by Symfony translation component.

Simple translation

You can use the key in a Twig template in Yves:

{{ 'say.hello' | trans }}

Sometimes you need to list all keys which are used in a template. Currently there is no good solution, but this regex will do the job pretty good:


Translation with placeholders

When you have a dynamic part in the translation, you can use placeholders.

Entry in glossary:

Key Value


“My name is %name%”

Now replace it with a value in the Twig template:

{{ "" | trans({'%name%' : 'Fabian'}, "app") }}

This will show “My name is Fabian”

Translation with ajax requests

To use an AJAX request, you need to send translated content directly from the controller. In Yves you can locate the translator and use it directly:


public function ajaxAction()
    $app = $this->getLocator()->application()->pluginPimple()->getApplication();   
    $text = $app->trans('what.ever');
    return $this->jsonResponse['text' => $text];