i18n
refers to both static content and dynamic content, even though both are handled very differently.i18next
package : Core dependencyreact-i18next
package : What we actually use in NRN, mostly throught the t
and Trans
component.t
function1
2
3
{t('examples.i18n.simpleTranslation', 'Traduction simple')}
count
property, which is the amount of items.1
2
3
{t('examples.i18n.pluralTranslation', 'Traduction avec gestion du pluriel', { count: 1 })}
1
2
3
{t('examples.i18n.pluralTranslation', 'Traduction avec gestion du pluriel', { count: 2 })}
1
2
3
4
5
6
7
8
<Trans
i18nKey={'examples.i18n.dynamicPluralTranslation'}
count={1}
>
Nous avons trouvé {{ count: 1 }} solution pour vous.
</Trans>
1
2
3
4
5
6
7
8
<Trans
i18nKey={'examples.i18n.dynamicPluralTranslation'}
count={2}
>
Nous avons trouvé {{ count: 2 }} solution pour vous.
</Trans>
1
2
3
4
5
6
7
8
9
10
11
12
<Trans
i18nKey={'examples.i18n.missingTranslationWithFallback'}
>
Cette phrase n'est pas traduite en anglais, et sera affichée en Français même quand la langue anglaise est utilisée<br />
(This sentence is not translated in English, and will be displayed in French even when English language is being used)<br />
<i>
Note that I actually translated it (within the same sentence), so that non-French speakers may understand the explanation/feature.<br />
Basically, if a static translation is not found in any non-primary language, then NRN automatically fall backs to another language, so that something gets displayed in any way.
</i>
</Trans>
"fr-x-customer2"
langage.1
2
3
4
5
6
7
8
9
10
11
<Trans
i18nKey={'examples.i18n.translationUsingCustomerVariation'}
>
Cette traduction est spécifique au customer "{{ customerRef: process.env.NEXT_PUBLIC_CUSTOMER_REF }}". <br />
Chaque customer peut surcharger ses propres traductions, en créant une clé Locize dans son <code>"{{ customerVariationLang: resolveCustomerVariationLang(lang)}}"</code> langage.<br />
Cette traduction va surcharger/remplacer la traduction de base, pour ce customer.<br />
<br />
Exemple:
</Trans>
Language
in Locize first, for instance: fr-x-customer1
and en-x-customer1
-x-
stands for "variation", it's the official way to create custom language variations that are specific to your business needs, when using i18next.Un autre okokok - 2021
Tous droits réservés