i18n in Vue apps ================ We use Gettext with `vue-gettext`_ to translate strings in our Vue apps. Here is some advice specific to ``vue-gettext``: * Always add a ``key`` attribute when you have conditional translated strings. For example, DO NOT do this: .. code-block:: html // TranslatedExample.vue The string in the ``v-else`` will never be shown, because Vue does not know that the two ``

`` tags actually have different content. Vue tries to limit the number of DOM changes, so it will only change attributes and will change the text node, which will mess up ``vue-gettext``. See `the Vue.js documentation on the key attribute `_ for details. INSTEAD, DO THIS: .. code-block:: html // TranslatedExample.vue * Never use Vue.js interpolation inside translated strings. For example, DO NOT do this: .. code-block:: html // TranslatedExample.vue This will break the translation. The string will always show in English, never in translated languages. Always use ``v-bind:translate-params="{ params }"`` or ``v-translate="{ params }"`` with ``%{ param }`` in the translated string. See `vue-gettext's syntax `_ INSTEAD, DO THIS: .. code-block:: html // TranslatedExample.vue * Never use ``v-bind`` on attributes in HTML tags in translated strings. For example, DO NOT do this: .. code-block:: html // TranslatedExample.vue This will break reactivity. If ``link_url`` or ``link_text`` change value, the text will not change. See `vue-gettext's doc about this `_. INSTEAD, DO THIS: .. code-block:: html // TranslatedExample.vue * Name your parameter when your translations have parameters. For example, DO NOT do this: .. code-block:: html // TranslatedExample.vue If your vue variable is updated, then you won't have to update the corresponding translation. INSTEAD, DO THIS: .. code-block:: html // TranslatedExample.vue Resources ^^^^^^^^^ - vue-gettext: https://github.com/Polyconseil/vue-gettext .. _vue-gettext: https://github.com/Polyconseil/vue-gettext