frontend/hooks/useTolgee.ts (view raw)
1import i18n from 'i18next';
2import {withTolgee, Tolgee, I18nextPlugin, DevTools} from '@tolgee/i18next';
3import useLocale from './useLocale';
4
5const tolgee = Tolgee()
6 .use(DevTools())
7 .use(I18nextPlugin())
8 .init({
9 apiUrl: process.env.NEXT_PUBLIC_TOLGEE_API_URL || 'https://app.tolgee.io',
10 apiKey: process.env.NEXT_PUBLIC_TOLGEE_API_KEY,
11 ns: ['common'],
12 });
13
14const useTolgee = () => {
15 const {locale} = useLocale();
16 return withTolgee(i18n, tolgee).init({
17 lng: locale,
18 fallbackLng: 'fr',
19 });
20};
21
22export default useTolgee;