i18n対応でテキスト中にリンクを埋め込む方法(react-i18nextの場合)
利用利用規約やプライバシーポリシーの
i18n対応の
Transコンポーネントを使う
翻訳ファイルに
{
"termsOfService": "<TermsLink>利用規約</TermsLink>に同意する。",
}
{
"termsOfService": "I accept and agree to <TermsLink>the Terms of Use</TermsLink>.",
}
import { Trans, useTranslation } from 'react-i18next';
function MyComponent() {
const { t } = useTranslation();
return (
<Trans
i18nKey={t("termsOfService")}
components={{
TermsLink: <Link href="https://hoge.app/terms" target="_blank"></Link>
}}
/>
);
}