25 lines
762 B
TypeScript
25 lines
762 B
TypeScript
|
|
import { i18n, registerTranslations } from "@repo/i18next";
|
||
|
|
import { useEffect } from "react";
|
||
|
|
import { useTranslation as useI18NextTranslation } from "react-i18next";
|
||
|
|
|
||
|
|
import enResources from "../common/locales/en.json";
|
||
|
|
import esResources from "../common/locales/es.json";
|
||
|
|
|
||
|
|
import { MODULE_NAME } from "./manifest";
|
||
|
|
|
||
|
|
export const ensureModuleTranslations = () => {
|
||
|
|
registerTranslations(MODULE_NAME, "en", enResources);
|
||
|
|
registerTranslations(MODULE_NAME, "es", esResources);
|
||
|
|
};
|
||
|
|
|
||
|
|
export const useTranslation = () => {
|
||
|
|
// biome-ignore lint/correctness/useExhaustiveDependencies: registro idempotente del namespace del módulo
|
||
|
|
useEffect(() => {
|
||
|
|
ensureModuleTranslations();
|
||
|
|
}, [i18n]);
|
||
|
|
|
||
|
|
return useI18NextTranslation(MODULE_NAME, {
|
||
|
|
i18n,
|
||
|
|
});
|
||
|
|
};
|