Skip to content

Latest commit

 

History

History
37 lines (27 loc) · 1.61 KB

File metadata and controls

37 lines (27 loc) · 1.61 KB
title last_updated template originalLink originalArticleId redirect_from
Using translations
Jun 16, 2021
howto-guide-template
ff253743-a10f-4866-8047-a6c8357a88a7
/docs/scos/dev/tutorials-and-howtos/advanced-tutorials/tutorial-using-translations.html

The data stored in the key-value storage can be used for multiple purposes:

  • URL mappings
  • Localized product details
  • Localized product categories details

Using twig translator

Twig Translator uses the data that comes from the Redis key-value storage. The glossary keys store static localized text that’s not likely to be subject of a change, like the caption of a label.

The format of the glossary keys is as follows: {store}.{locale}.glossary.translation.{glossary_key}

Example:

  • key : demo.de_de.glossary.translation.catalog.next
  • value : weiter
<div class="catalog__pagination">
    <button class="pagination__button js-pagination-prev">{% raw %}{{{% endraw %} 'catalog.prev' | trans {% raw %}}}{% endraw %}</button>
    <button class="pagination__button js-pagination-next">{% raw %}{{{% endraw %} 'catalog.next' | trans {% raw %}}}{% endraw %}</button>
</div>

The following example shows how to use the Twig Translator:

When the page containing this template is requested, the Twig Translator will replace the text containing the key (for example, catalog.next) with the value of the key stored in Redis that corresponds to the current locale (for example, for locale de_DE, will replace with the value of the key demo.de_de.glossary.translation.catalog.next).