🔥 Remove type safety for translations
This commit is contained in:
Vendored
-127
@@ -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 { COOKIE_LOCALE_KEY } from '../../../data/constants';
|
||||
import { TranslationNamespace } from '~/i18n';
|
||||
|
||||
export const getServerSideTranslations = async (
|
||||
namespaces: TranslationNamespace[],
|
||||
namespaces: string[],
|
||||
requestLocale?: string,
|
||||
req?: IncomingMessage,
|
||||
res?: ServerResponse
|
||||
|
||||
@@ -1,6 +1,4 @@
|
||||
import { TranslationNamespace } from '~/i18n';
|
||||
|
||||
export const boardNamespaces: TranslationNamespace[] = [
|
||||
export const boardNamespaces = [
|
||||
'common',
|
||||
'zod',
|
||||
'layout/element-selector/selector',
|
||||
@@ -43,14 +41,14 @@ export const boardNamespaces: TranslationNamespace[] = [
|
||||
'boards/common',
|
||||
];
|
||||
|
||||
export const manageNamespaces: TranslationNamespace[] = [
|
||||
export const manageNamespaces = [
|
||||
'user/preferences',
|
||||
'boards/manage',
|
||||
'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 { DashDotCompactStorage } from './DashDotCompactStorage';
|
||||
|
||||
import { CustomTypeOptions } from 'i18next';
|
||||
|
||||
type GraphType = keyof CustomTypeOptions['resources']['modules/dashdot']['card']['graphs'];
|
||||
|
||||
interface DashDotGraphProps {
|
||||
graph: GraphType;
|
||||
graph: string;
|
||||
graphHeight: number;
|
||||
isCompact: boolean;
|
||||
multiView: boolean;
|
||||
|
||||
@@ -11,7 +11,6 @@ import {
|
||||
IconSun,
|
||||
} from '@tabler/icons-react';
|
||||
import { useTranslation } from 'next-i18next';
|
||||
import { TranslationNamespace } from '~/i18n';
|
||||
import { CustomTypeOptions } from 'i18next';
|
||||
|
||||
interface WeatherIconProps {
|
||||
@@ -38,9 +37,7 @@ export const WeatherIcon = ({ code }: WeatherIconProps) => {
|
||||
);
|
||||
};
|
||||
|
||||
|
||||
type WeatherDescription = keyof CustomTypeOptions['resources']['modules/weather']['card']['weatherDescriptions'];
|
||||
type WeatherDefinitionType = { icon: Icon; name: WeatherDescription; codes: number[] };
|
||||
type WeatherDefinitionType = { icon: Icon; name: string; codes: number[] };
|
||||
|
||||
// 0 Clear sky
|
||||
// 1, 2, 3 Mainly clear, partly cloudy, and overcast
|
||||
|
||||
Reference in New Issue
Block a user