Shop translations ¶
You can use special translation Content items called "text modules" to create translations of the interface. The translation service first checks if a Content item with a specific identifier exists and then returns the text attribute of this object. If it does not find any translations, the standard Symfony translation service is used.
The translation service offers the Twig filter
The filter uses a code which identifies the text to be translated and an optional context.
The context can be used to differentiate between different meanings, e.g. in the shop context
order refers to purchasing,
but in content management it can refer to sorting content.
1 2 3
When you use Symfony translation service instead of text modules, you can use a message with placeholders
and define a different translation domain, in this example,
1 2 3
Specifying translation language¶
By default the translation service uses the language of the current SiteAccess and the current locale. You can additionally send the language as a parameter.
The translation service can use the given SiteAccess to specify the language or locale required for the translation process.
1 2 3
To handle plurals in translations, use Symfony pluralization.
Translation in PHP code¶
In PHP code you can use the
Ibexa\Bundle\Commerce\Translation\Services\TransService service to get translations:
1 2 3 4 5 6 7 8
Translations with text modules¶
The Content Type
st_textmodule has the following Fields:
|Identifier||The source or identifier for the translation that has to be defined.|
|Content||Content for frontend|
By default the translated value is taken from the
You can extend the text module Content Type with a new RichText Field.
Then, the translation service can fetch from the appropriate Field.
To take advantage of this, use the
1 2 3 4
||Location ID of the text module folder||
||Enable/disable text modules||
||Enable/disable default Symfony translation||
||Enable/disable logging missing translations||
||Enable/disable translation cache||
||Defines how long the translation is stored in the cache. When the TTL value is set to
Missing translations are logged.
You can enable/disable logging of missing translations in the configuration with the
All missing translations are logged in
1 2 3
Translations are cached using Stash. If there is no translation for the given message (or code),
null translation message is cached. Thanks to this there is no need to repeat fetches.
Translations from Symfony are not cached.
ibexa_commerce_translate() is used in Twig templates, the cache is tagged with
If a text module is updated, the system purges all HTTP cache blocks which are tagged with the given
as well as the Stash cache for this translation.