mirror of
https://github.com/ajnart/homarr.git
synced 2025-11-14 09:25:47 +01:00
🔥 Remove type safety for translations
This commit is contained in:
@@ -76,7 +76,7 @@
|
|||||||
"js-file-download": "^0.4.12",
|
"js-file-download": "^0.4.12",
|
||||||
"next": "13.4.10",
|
"next": "13.4.10",
|
||||||
"next-auth": "^4.22.3",
|
"next-auth": "^4.22.3",
|
||||||
"next-i18next": "^13.0.0",
|
"next-i18next": "^14.0.0",
|
||||||
"nzbget-api": "^0.0.3",
|
"nzbget-api": "^0.0.3",
|
||||||
"prisma": "^5.0.0",
|
"prisma": "^5.0.0",
|
||||||
"prismjs": "^1.29.0",
|
"prismjs": "^1.29.0",
|
||||||
|
|||||||
127
src/i18n.d.ts
vendored
127
src/i18n.d.ts
vendored
@@ -1,127 +0,0 @@
|
|||||||
import 'i18next';
|
|
||||||
|
|
||||||
import authInvite from '../public/locales/en/authentication/invite.json';
|
|
||||||
import authLogin from '../public/locales/en/authentication/login.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 layout from '../public/locales/en/layout/common.json';
|
|
||||||
import layoutElementSelector from '../public/locales/en/layout/element-selector/selector.json';
|
|
||||||
import layoutHeader from '../public/locales/en/layout/header.json';
|
|
||||||
import layoutToggleEditMode from '../public/locales/en/layout/header/actions/toggle-edit-mode.json';
|
|
||||||
import layoutMobileDrawer from '../public/locales/en/layout/mobile/drawer.json';
|
|
||||||
import layoutModalAbout from '../public/locales/en/layout/modals/about.json';
|
|
||||||
import layoutModalAddApp from '../public/locales/en/layout/modals/add-app.json';
|
|
||||||
import layoutModalChangePosition from '../public/locales/en/layout/modals/change-position.json';
|
|
||||||
import moduleBookmark from '../public/locales/en/modules/bookmark.json';
|
|
||||||
import moduleCalendar from '../public/locales/en/modules/calendar.json';
|
|
||||||
import moduleMediaCards from '../public/locales/en/modules/common-media-cards.json';
|
|
||||||
import moduleCommon from '../public/locales/en/modules/common.json';
|
|
||||||
import moduleDashDot from '../public/locales/en/modules/dashdot.json';
|
|
||||||
import moduleDate from '../public/locales/en/modules/date.json';
|
|
||||||
import moduleDownload from '../public/locales/en/modules/dlspeed.json';
|
|
||||||
import moduleDnsHoleControls from '../public/locales/en/modules/dns-hole-controls.json';
|
|
||||||
import moduleDnsHoleSummary from '../public/locales/en/modules/dns-hole-summary.json';
|
|
||||||
import moduleDocker from '../public/locales/en/modules/docker.json';
|
|
||||||
import moduleIframe from '../public/locales/en/modules/iframe.json';
|
|
||||||
import moduleMediaRequests from '../public/locales/en/modules/media-requests-list.json';
|
|
||||||
import moduleMediaRequestsStats from '../public/locales/en/modules/media-requests-stats.json';
|
|
||||||
import moduleMediaServer from '../public/locales/en/modules/media-server.json';
|
|
||||||
import moduleOverseerr from '../public/locales/en/modules/overseerr.json';
|
|
||||||
import modulePing from '../public/locales/en/modules/ping.json';
|
|
||||||
import moduleRss from '../public/locales/en/modules/rss.json';
|
|
||||||
import moduleSearch from '../public/locales/en/modules/search.json';
|
|
||||||
import moduleTorrentStatus from '../public/locales/en/modules/torrents-status.json';
|
|
||||||
import moduleUsenet from '../public/locales/en/modules/usenet.json';
|
|
||||||
import moduleVideoStream from '../public/locales/en/modules/video-stream.json';
|
|
||||||
import moduleWeather from '../public/locales/en/modules/weather.json';
|
|
||||||
import settingsCommon from '../public/locales/en/settings/common.json';
|
|
||||||
import settingsAppWidth from '../public/locales/en/settings/customization/app-width.json';
|
|
||||||
import settingsColorSelector from '../public/locales/en/settings/customization/color-selector.json';
|
|
||||||
import settingsGeneral from '../public/locales/en/settings/customization/general.json';
|
|
||||||
import settingsGridstack from '../public/locales/en/settings/customization/gridstack.json';
|
|
||||||
import settingsOpacitySelector from '../public/locales/en/settings/customization/opacity-selector.json';
|
|
||||||
import settingsPageAppearance from '../public/locales/en/settings/customization/page-appearance.json';
|
|
||||||
import settingsShadeSelector from '../public/locales/en/settings/customization/shade-selector.json';
|
|
||||||
import settingsColorSchema from '../public/locales/en/settings/general/color-schema.json';
|
|
||||||
import settingsConfigChanger from '../public/locales/en/settings/general/config-changer.json';
|
|
||||||
import settingsInternationalization from '../public/locales/en/settings/general/internationalization.json';
|
|
||||||
import settingsSearchEngine from '../public/locales/en/settings/general/search-engine.json';
|
|
||||||
import settingsThemeSelector from '../public/locales/en/settings/general/theme-selector.json';
|
|
||||||
import settingsWidgetPositions from '../public/locales/en/settings/general/widget-positions.json';
|
|
||||||
import userPreferences from '../public/locales/en/user/preferences.json';
|
|
||||||
import widgetsDraggableList from '../public/locales/en/widgets/draggable-list.json';
|
|
||||||
import widgetsErrorBoundary from '../public/locales/en/widgets/error-boundary.json';
|
|
||||||
import widgetsLocation from '../public/locales/en/widgets/location.json';
|
|
||||||
import zod from '../public/locales/en/zod.json';
|
|
||||||
|
|
||||||
declare module 'i18next' {
|
|
||||||
// Extend CustomTypeOptions
|
|
||||||
interface CustomTypeOptions {
|
|
||||||
// custom namespace type, if you changed it
|
|
||||||
defaultNS: 'ns1';
|
|
||||||
// custom resources type
|
|
||||||
resources: {
|
|
||||||
common: typeof common;
|
|
||||||
zod: typeof zod;
|
|
||||||
'authentication/invite': typeof authInvite;
|
|
||||||
'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
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
import { CustomTypeOptions } from 'i18next';
|
|
||||||
export type TranslationNamespace = keyof CustomTypeOptions['resources'];
|
|
||||||
@@ -3,10 +3,9 @@ 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: TranslationNamespace[],
|
namespaces: string[],
|
||||||
requestLocale?: string,
|
requestLocale?: string,
|
||||||
req?: IncomingMessage,
|
req?: IncomingMessage,
|
||||||
res?: ServerResponse
|
res?: ServerResponse
|
||||||
|
|||||||
@@ -1,6 +1,4 @@
|
|||||||
import { TranslationNamespace } from '~/i18n';
|
export const boardNamespaces = [
|
||||||
|
|
||||||
export const boardNamespaces: TranslationNamespace[] = [
|
|
||||||
'common',
|
'common',
|
||||||
'zod',
|
'zod',
|
||||||
'layout/element-selector/selector',
|
'layout/element-selector/selector',
|
||||||
@@ -43,14 +41,14 @@ export const boardNamespaces: TranslationNamespace[] = [
|
|||||||
'boards/common',
|
'boards/common',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const manageNamespaces: TranslationNamespace[] = [
|
export const manageNamespaces = [
|
||||||
'user/preferences',
|
'user/preferences',
|
||||||
'boards/manage',
|
'boards/manage',
|
||||||
'zod',
|
'zod',
|
||||||
];
|
];
|
||||||
|
|
||||||
export const loginNamespaces: TranslationNamespace[] = ['authentication/login', 'zod'];
|
export const loginNamespaces = ['authentication/login', 'zod'];
|
||||||
|
|
||||||
export const inviteNamespaces: TranslationNamespace[] = ['authentication/invite', 'zod'];
|
export const inviteNamespaces = ['authentication/invite', 'zod'];
|
||||||
|
|
||||||
export const onboardNamespaces: TranslationNamespace[] = ['common', 'zod'];
|
export const onboardNamespaces = ['common', 'zod'];
|
||||||
|
|||||||
@@ -4,12 +4,8 @@ import { useTranslation } from 'next-i18next';
|
|||||||
import { DashDotCompactNetwork, DashDotInfo } from './DashDotCompactNetwork';
|
import { DashDotCompactNetwork, DashDotInfo } from './DashDotCompactNetwork';
|
||||||
import { DashDotCompactStorage } from './DashDotCompactStorage';
|
import { DashDotCompactStorage } from './DashDotCompactStorage';
|
||||||
|
|
||||||
import { CustomTypeOptions } from 'i18next';
|
|
||||||
|
|
||||||
type GraphType = keyof CustomTypeOptions['resources']['modules/dashdot']['card']['graphs'];
|
|
||||||
|
|
||||||
interface DashDotGraphProps {
|
interface DashDotGraphProps {
|
||||||
graph: GraphType;
|
graph: string;
|
||||||
graphHeight: number;
|
graphHeight: number;
|
||||||
isCompact: boolean;
|
isCompact: boolean;
|
||||||
multiView: boolean;
|
multiView: boolean;
|
||||||
|
|||||||
@@ -11,7 +11,6 @@ import {
|
|||||||
IconSun,
|
IconSun,
|
||||||
} from '@tabler/icons-react';
|
} from '@tabler/icons-react';
|
||||||
import { useTranslation } from 'next-i18next';
|
import { useTranslation } from 'next-i18next';
|
||||||
import { TranslationNamespace } from '~/i18n';
|
|
||||||
import { CustomTypeOptions } from 'i18next';
|
import { CustomTypeOptions } from 'i18next';
|
||||||
|
|
||||||
interface WeatherIconProps {
|
interface WeatherIconProps {
|
||||||
@@ -38,9 +37,7 @@ export const WeatherIcon = ({ code }: WeatherIconProps) => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type WeatherDefinitionType = { icon: Icon; name: string; codes: number[] };
|
||||||
type WeatherDescription = keyof CustomTypeOptions['resources']['modules/weather']['card']['weatherDescriptions'];
|
|
||||||
type WeatherDefinitionType = { icon: Icon; name: WeatherDescription; codes: number[] };
|
|
||||||
|
|
||||||
// 0 Clear sky
|
// 0 Clear sky
|
||||||
// 1, 2, 3 Mainly clear, partly cloudy, and overcast
|
// 1, 2, 3 Mainly clear, partly cloudy, and overcast
|
||||||
|
|||||||
18
yarn.lock
18
yarn.lock
@@ -5909,7 +5909,7 @@ __metadata:
|
|||||||
js-file-download: ^0.4.12
|
js-file-download: ^0.4.12
|
||||||
next: 13.4.10
|
next: 13.4.10
|
||||||
next-auth: ^4.22.3
|
next-auth: ^4.22.3
|
||||||
next-i18next: ^13.0.0
|
next-i18next: ^14.0.0
|
||||||
node-mocks-http: ^1.12.2
|
node-mocks-http: ^1.12.2
|
||||||
nzbget-api: ^0.0.3
|
nzbget-api: ^0.0.3
|
||||||
prettier: ^3.0.0
|
prettier: ^3.0.0
|
||||||
@@ -6083,7 +6083,7 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"i18next-fs-backend@npm:^2.1.1":
|
"i18next-fs-backend@npm:^2.1.5":
|
||||||
version: 2.1.5
|
version: 2.1.5
|
||||||
resolution: "i18next-fs-backend@npm:2.1.5"
|
resolution: "i18next-fs-backend@npm:2.1.5"
|
||||||
checksum: 4607e879de8195ff0bf11bdb2367f1c45f947160404b64f52be7e438ae27288e0d11a9b53a4bde2d75a77ac7f3255aa531a4381870e278e72f85ead222ffed31
|
checksum: 4607e879de8195ff0bf11bdb2367f1c45f947160404b64f52be7e438ae27288e0d11a9b53a4bde2d75a77ac7f3255aa531a4381870e278e72f85ead222ffed31
|
||||||
@@ -7402,21 +7402,21 @@ __metadata:
|
|||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"next-i18next@npm:^13.0.0":
|
"next-i18next@npm:^14.0.0":
|
||||||
version: 13.3.0
|
version: 14.0.0
|
||||||
resolution: "next-i18next@npm:13.3.0"
|
resolution: "next-i18next@npm:14.0.0"
|
||||||
dependencies:
|
dependencies:
|
||||||
"@babel/runtime": ^7.20.13
|
"@babel/runtime": ^7.20.13
|
||||||
"@types/hoist-non-react-statics": ^3.3.1
|
"@types/hoist-non-react-statics": ^3.3.1
|
||||||
core-js: ^3
|
core-js: ^3
|
||||||
hoist-non-react-statics: ^3.3.2
|
hoist-non-react-statics: ^3.3.2
|
||||||
i18next-fs-backend: ^2.1.1
|
i18next-fs-backend: ^2.1.5
|
||||||
peerDependencies:
|
peerDependencies:
|
||||||
i18next: ^22.0.6
|
i18next: ^23.0.1
|
||||||
next: ">= 12.0.0"
|
next: ">= 12.0.0"
|
||||||
react: ">= 17.0.2"
|
react: ">= 17.0.2"
|
||||||
react-i18next: ^12.2.0
|
react-i18next: ^13.0.0
|
||||||
checksum: 4c3aa5bbbc12964ed6f61f37d33f4319abd04932d6871baba9f209183952b286470fff80f90a94ccddba736c8fb13a9238effa1e8247dfb08e2239cbdc4fb769
|
checksum: a699f6fdee650a2456c463d59910bf38d9f891d224c00de639b15740e8cbf939a2469c8c733007b4f1c2fe0f85c18d43b6f1e814f2127ef30a0d3a28a354dc1d
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user