15 lines
536 B
TypeScript
15 lines
536 B
TypeScript
|
|
import i18next from "i18next";
|
||
|
|
import { useTranslation as useTrans } from "react-i18next";
|
||
|
|
import { PACKAGE_NAME } from "../index.ts";
|
||
|
|
import enResources from "./en.json" with { type: "json" };
|
||
|
|
import esResources from "./es.json" with { type: "json" };
|
||
|
|
|
||
|
|
export const useTranslation = () => {
|
||
|
|
if (!i18next.hasLoadedNamespace(PACKAGE_NAME)) {
|
||
|
|
i18next.addResourceBundle("en", PACKAGE_NAME, enResources, true, true);
|
||
|
|
i18next.addResourceBundle("es", PACKAGE_NAME, esResources, true, true);
|
||
|
|
}
|
||
|
|
|
||
|
|
return useTrans(PACKAGE_NAME);
|
||
|
|
};
|