mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-18 03:01:09 +01:00
🏷️ Add translation namespace typesy
This commit is contained in:
60
src/i18n.d.ts
vendored
60
src/i18n.d.ts
vendored
@@ -2,7 +2,9 @@ import 'i18next';
|
|||||||
|
|
||||||
import authInvite from '../public/locales/en/authentication/invite.json';
|
import authInvite from '../public/locales/en/authentication/invite.json';
|
||||||
import authLogin from '../public/locales/en/authentication/login.json';
|
import authLogin from '../public/locales/en/authentication/login.json';
|
||||||
import manageBoards from '../public/locales/en/boards/manage.json';
|
import boardsManage from '../public/locales/en/boards/manage.json';
|
||||||
|
import boardsCommon from '../public/locales/en/boards/common.json';
|
||||||
|
import boardsCustomize from '../public/locales/en/boards/customize.json';
|
||||||
import common from '../public/locales/en/common.json';
|
import common from '../public/locales/en/common.json';
|
||||||
import layout from '../public/locales/en/layout/common.json';
|
import layout from '../public/locales/en/layout/common.json';
|
||||||
import layoutElementSelector from '../public/locales/en/layout/element-selector/selector.json';
|
import layoutElementSelector from '../public/locales/en/layout/element-selector/selector.json';
|
||||||
@@ -64,8 +66,62 @@ declare module 'i18next' {
|
|||||||
common: typeof common;
|
common: typeof common;
|
||||||
zod: typeof zod;
|
zod: typeof zod;
|
||||||
'authentication/invite': typeof authInvite;
|
'authentication/invite': typeof authInvite;
|
||||||
'boards/manage': typeof manageBoards;
|
'authentication/login': typeof authLogin;
|
||||||
|
'boards/common': typeof boardsCommon;
|
||||||
|
'boards/manage': typeof boardsManage;
|
||||||
|
'boards/customize': typeof boardsCustomize;
|
||||||
|
'layout/common': typeof layout;
|
||||||
|
'layout/element-selector/selector': typeof layoutElementSelector;
|
||||||
|
'layout/header': typeof layoutHeader;
|
||||||
|
'layout/header/actions/toggle-edit-mode': typeof layoutToggleEditMode;
|
||||||
|
'layout/mobile/drawer': typeof layoutMobileDrawer;
|
||||||
|
'layout/modals/about': typeof layoutModalAbout;
|
||||||
|
'layout/modals/add-app': typeof layoutModalAddApp;
|
||||||
|
'layout/modals/change-position': typeof layoutModalChangePosition;
|
||||||
|
'modules/bookmark': typeof moduleBookmark;
|
||||||
|
'modules/calendar': typeof moduleCalendar;
|
||||||
|
'modules/common-media-cards': typeof moduleMediaCards;
|
||||||
|
'modules/common': typeof moduleCommon;
|
||||||
|
'modules/dashdot': typeof moduleDashDot;
|
||||||
|
'modules/date': typeof moduleDate;
|
||||||
|
'modules/dlspeed': typeof moduleDownload;
|
||||||
|
'modules/dns-hole-controls': typeof moduleDnsHoleControls;
|
||||||
|
'modules/dns-hole-summary': typeof moduleDnsHoleSummary;
|
||||||
|
'modules/docker': typeof moduleDocker;
|
||||||
|
'modules/iframe': typeof moduleIframe;
|
||||||
|
'modules/media-requests-list': typeof moduleMediaRequests;
|
||||||
|
'modules/media-requests-stats': typeof moduleMediaRequestsStats;
|
||||||
|
'modules/media-server': typeof moduleMediaServer;
|
||||||
|
'modules/overseerr': typeof moduleOverseerr;
|
||||||
|
'modules/ping': typeof modulePing;
|
||||||
|
'modules/rss': typeof moduleRss;
|
||||||
|
'modules/search': typeof moduleSearch;
|
||||||
|
'modules/torrents-status': typeof moduleTorrentStatus;
|
||||||
|
'modules/usenet': typeof moduleUsenet;
|
||||||
|
'modules/video-stream': typeof moduleVideoStream;
|
||||||
|
'modules/weather': typeof moduleWeather;
|
||||||
|
'settings/common': typeof settingsCommon;
|
||||||
|
'settings/customization/app-width': typeof settingsAppWidth;
|
||||||
|
'settings/customization/color-selector': typeof settingsColorSelector;
|
||||||
|
'settings/customization/general': typeof settingsGeneral;
|
||||||
|
'settings/customization/gridstack': typeof settingsGridstack;
|
||||||
|
'settings/customization/opacity-selector': typeof settingsOpacitySelector;
|
||||||
|
'settings/customization/page-appearance': typeof settingsPageAppearance;
|
||||||
|
'settings/customization/shade-selector': typeof settingsShadeSelector;
|
||||||
|
'settings/general/color-schema': typeof settingsColorSchema;
|
||||||
|
'settings/general/config-changer': typeof settingsConfigChanger;
|
||||||
|
'settings/general/internationalization': typeof settingsInternationalization;
|
||||||
|
'settings/general/search-engine': typeof settingsSearchEngine;
|
||||||
|
'settings/general/theme-selector': typeof settingsThemeSelector;
|
||||||
|
'settings/general/widget-positions': typeof settingsWidgetPositions;
|
||||||
|
'user/preferences': typeof userPreferences;
|
||||||
|
'widgets/draggable-list': typeof widgetsDraggableList;
|
||||||
|
'widgets/error-boundary': typeof widgetsErrorBoundary;
|
||||||
|
'widgets/location': typeof widgetsLocation;
|
||||||
};
|
};
|
||||||
// other
|
// other
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
import { CustomTypeOptions } from 'i18next';
|
||||||
|
export type TranslationNamespace = keyof CustomTypeOptions['resources'];
|
||||||
@@ -11,7 +11,6 @@ import {
|
|||||||
} from '@mantine/core';
|
} from '@mantine/core';
|
||||||
import { useForm } from '@mantine/form';
|
import { useForm } from '@mantine/form';
|
||||||
import { IconAlertTriangle } from '@tabler/icons-react';
|
import { IconAlertTriangle } from '@tabler/icons-react';
|
||||||
import { useMutation } from '@tanstack/react-query';
|
|
||||||
import { GetServerSideProps } from 'next';
|
import { GetServerSideProps } from 'next';
|
||||||
import { signIn } from 'next-auth/react';
|
import { signIn } from 'next-auth/react';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
@@ -27,7 +26,7 @@ import { signInSchema } from '~/validations/user';
|
|||||||
import { loginNamespaces } from '../../tools/server/translation-namespaces';
|
import { loginNamespaces } from '../../tools/server/translation-namespaces';
|
||||||
|
|
||||||
export default function LoginPage() {
|
export default function LoginPage() {
|
||||||
const { t } = useTranslation(['authentication/login']);
|
const { t } = useTranslation('authentication/login');
|
||||||
const queryParams = useRouter().query as { error?: 'CredentialsSignin' | (string & {}) };
|
const queryParams = useRouter().query as { error?: 'CredentialsSignin' | (string & {}) };
|
||||||
const { i18nZodResolver } = useI18nZodResolver();
|
const { i18nZodResolver } = useI18nZodResolver();
|
||||||
const router = useRouter();
|
const router = useRouter();
|
||||||
|
|||||||
@@ -3,9 +3,10 @@ import { IncomingMessage, ServerResponse } from 'http';
|
|||||||
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
import { serverSideTranslations } from 'next-i18next/serverSideTranslations';
|
||||||
|
|
||||||
import { COOKIE_LOCALE_KEY } from '../../../data/constants';
|
import { COOKIE_LOCALE_KEY } from '../../../data/constants';
|
||||||
|
import { TranslationNamespace } from '~/i18n';
|
||||||
|
|
||||||
export const getServerSideTranslations = async (
|
export const getServerSideTranslations = async (
|
||||||
namespaces: string[],
|
namespaces: TranslationNamespace[],
|
||||||
requestLocale?: string,
|
requestLocale?: string,
|
||||||
req?: IncomingMessage,
|
req?: IncomingMessage,
|
||||||
res?: ServerResponse
|
res?: ServerResponse
|
||||||
|
|||||||
@@ -1,4 +1,6 @@
|
|||||||
export const boardNamespaces = [
|
import { TranslationNamespace } from '~/i18n';
|
||||||
|
|
||||||
|
export const boardNamespaces: TranslationNamespace[] = [
|
||||||
'common',
|
'common',
|
||||||
'zod',
|
'zod',
|
||||||
'layout/element-selector/selector',
|
'layout/element-selector/selector',
|
||||||
@@ -41,10 +43,14 @@ export const boardNamespaces = [
|
|||||||
'boards/common',
|
'boards/common',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const manageNamespaces = ['user/preferences', 'boards/manage', 'zod'];
|
export const manageNamespaces: TranslationNamespace[] = [
|
||||||
|
'user/preferences',
|
||||||
|
'boards/manage',
|
||||||
|
'zod',
|
||||||
|
];
|
||||||
|
|
||||||
export const loginNamespaces = ['authentication/login', 'zod'];
|
export const loginNamespaces: TranslationNamespace[] = ['authentication/login', 'zod'];
|
||||||
|
|
||||||
export const inviteNamespaces = ['authentication/invite', 'zod'];
|
export const inviteNamespaces: TranslationNamespace[] = ['authentication/invite', 'zod'];
|
||||||
|
|
||||||
export const onboardNamespaces = ['common', 'zod'];
|
export const onboardNamespaces: TranslationNamespace[] = ['common', 'zod'];
|
||||||
|
|||||||
Reference in New Issue
Block a user