Skip to content

Document how to correctly use i18n translations in JS modules #640

@baptistegrimaud

Description

@baptistegrimaud

Description

Write a dedicate section/page about how internalization should be used within JavaScript modules, in particular when components from different modules are used on the same page.

For now, we only have this comment:

// IMPORTANT: Always use useTranslation() (not { t } from "i18next") in React components.

TL;DR

In short, we should always use:

import { useTranslation } from "react-i18next";
...
const { t } = useTranslation();
...
<p>{t("my-key")}</p>

For both client and server code.

Metadata

Metadata

Assignees

No one assigned

    Labels

    documentationImprovements or additions to documentation

    Type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions