localization

This commit is contained in:
2026-02-17 21:36:12 +00:00
parent 3733e99ba8
commit 680f623b41
17 changed files with 341 additions and 71 deletions
+23
View File
@@ -0,0 +1,23 @@
import type { ReactNode } from 'react';
import type { TranslationMap } from 'i18n';
import { I18nProvider } from 'i18n';
import { useSettings } from '@/state/useSettings';
import en from '../locales/en.json';
import pt from '../locales/pt.json';
const translations: TranslationMap = { en, pt };
type I18nBridgeProps = {
children: ReactNode;
};
export const I18nBridge = ({ children }: I18nBridgeProps) => {
const { settings } = useSettings();
const locale = settings.languages.default;
return (
<I18nProvider translations={translations} locale={locale}>
{children}
</I18nProvider>
);
};
+12
View File
@@ -0,0 +1,12 @@
import type { TranslationKeys } from 'i18n';
import type { InterpolationParams } from 'i18n';
import { useTranslation as useTranslationBase } from 'i18n';
import type en from '../locales/en.json';
type AppTranslationKey = TranslationKeys<typeof en>;
export const useTranslation = () => {
const { t: baseT, locale } = useTranslationBase();
const t = (key: AppTranslationKey, params?: InterpolationParams) => baseT(key, params);
return { t, locale };
};