#
useI18nextInstance
Retrieve a registered i18next instance from the i18nextPlugin instance.
#
Reference
const instance = useI18nextInstance(key)
#
Parameters
key
: An instance key.
#
Returns
An i18next
instance.
#
Usage
#
Retrieve an instance
import { useI18nextInstance } from "@squide/i18next";
const instance = useI18nextInstance("an-instance-key");
#
Use with the useTranslation hook
import { useI18nextInstance } from "@squide/i18next";
import { useTranslation } from "react-i18next";
const instance = useI18nextInstance("an-instance-key");
const { t } = useTranslation("a-namespace", {
i18n: instance
});
#
Use with the Trans component
import { useI18nextInstance } from "@squide/i18next";
import { Trans, useTranslation } from "react-i18next";
const instance = useI18nextInstance("an-instance-key");
const { t } = useTranslation("a-namespace", { i18n: instance });
return (
<Trans
i18n={instance}
i18nKey="a-key"
t={t}
/>
);
Or without the t
function:
import { useI18nextInstance } from "@squide/i18next";
import { Trans, useTranslation } from "react-i18next";
const instance = useI18nextInstance("an-instance-key");
return (
<Trans
i18n={instance}
i18nKey="a-namespace:a-key"
/>
);