perf: cut cold route compilation and unblock preview images (#6441)
This commit is contained in:
1 parent
622e1dcfa5
commit
b32ad82850
182 files changed
+11421
-2339
No files matched your search
@@ -15,13 +15,10 @@ declare module "next-intl" {
|
||||
}
|
||||
}
|
||||
|
||||
export const { useI18n, useScopedI18n } = {
|
||||
useI18n: useTranslations,
|
||||
useScopedI18n: useTranslations,
|
||||
};
|
||||
|
||||
export const { useI18nMessages } = {
|
||||
useI18nMessages: () => useMessages(),
|
||||
};
|
||||
// Keep these as direct exports so Turbopack and webpack can statically inspect
|
||||
// the client package's public surface.
|
||||
export const useI18n = useTranslations;
|
||||
export const useScopedI18n = useTranslations;
|
||||
export const useI18nMessages = () => useMessages();
|
||||
|
||||
export { useTranslations };
|
||||
@@ -1,6 +1,9 @@
|
||||
import type { MRT_Localization } from "mantine-react-table";
|
||||
|
||||
import { objectKeys } from "@homarr/common";
|
||||
import type { SupportedLanguage } from "./languages";
|
||||
|
||||
export { supportedLanguages } from "./languages";
|
||||
export type { SupportedLanguage } from "./languages";
|
||||
|
||||
export const localeConfigurations = {
|
||||
ca: {
|
||||
@@ -433,10 +436,7 @@ export type LanguageIconDefinition =
|
||||
url: string;
|
||||
};
|
||||
|
||||
export const supportedLanguages = objectKeys(localeConfigurations);
|
||||
export type SupportedLanguage = (typeof supportedLanguages)[number];
|
||||
|
||||
export const fallbackLocale = "en" satisfies SupportedLanguage;
|
||||
export { fallbackLocale } from "./languages";
|
||||
|
||||
export const isLocaleRTL = (locale: SupportedLanguage) =>
|
||||
"isRTL" in localeConfigurations[locale] && localeConfigurations[locale].isRTL;
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { SupportedLanguage } from "./config";
|
||||
import { supportedLanguages } from "./config";
|
||||
import type { SupportedLanguage } from "./languages";
|
||||
import { supportedLanguages } from "./languages";
|
||||
import type { stringOrTranslation, TranslationFunction } from "./type";
|
||||
|
||||
export * from "./type";
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import { localeConfigurations } from "./config";
|
||||
import { supportedLanguages } from "./languages";
|
||||
|
||||
describe("supported translation languages", () => {
|
||||
it("matches the locale configuration registry", () => {
|
||||
expect(Object.keys(localeConfigurations)).toEqual([...supportedLanguages]);
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,46 @@
|
||||
/**
|
||||
* Keep the locale list dependency-free. This module is used by Next's proxy,
|
||||
* where importing the full translation barrel would widen every route graph.
|
||||
*/
|
||||
export const supportedLanguages = [
|
||||
"ca",
|
||||
"cn",
|
||||
"cr",
|
||||
"cs",
|
||||
"da",
|
||||
"de",
|
||||
"de-CH",
|
||||
"en-gb",
|
||||
"en",
|
||||
"el",
|
||||
"es",
|
||||
"et",
|
||||
"fi",
|
||||
"fr",
|
||||
"he",
|
||||
"hr",
|
||||
"hu",
|
||||
"it",
|
||||
"ja",
|
||||
"ko",
|
||||
"lt",
|
||||
"lv",
|
||||
"nl",
|
||||
"no",
|
||||
"pl",
|
||||
"pt",
|
||||
"pt-br",
|
||||
"ro",
|
||||
"ru",
|
||||
"sk",
|
||||
"sl",
|
||||
"sv",
|
||||
"tr",
|
||||
"zh",
|
||||
"uk",
|
||||
"vi",
|
||||
] as const;
|
||||
|
||||
export type SupportedLanguage = (typeof supportedLanguages)[number];
|
||||
|
||||
export const fallbackLocale = "en" satisfies SupportedLanguage;
|
||||
@@ -1,7 +1,7 @@
|
||||
import createMiddleware from "next-intl/middleware";
|
||||
|
||||
import type { SupportedLanguage } from ".";
|
||||
import { supportedLanguages } from "./config";
|
||||
import { supportedLanguages } from "./languages";
|
||||
import { createRouting } from "./routing";
|
||||
|
||||
export const createI18nMiddleware = (defaultLocale: SupportedLanguage) =>
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
import { defineRouting } from "next-intl/routing";
|
||||
|
||||
import { localeCookieKey } from "@homarr/definitions";
|
||||
import { localeCookieKey } from "@homarr/definitions/cookie";
|
||||
|
||||
import type { SupportedLanguage } from "./config";
|
||||
import { supportedLanguages } from "./config";
|
||||
import type { SupportedLanguage } from "./languages";
|
||||
import { supportedLanguages } from "./languages";
|
||||
|
||||
export const createRouting = (defaultLocale: SupportedLanguage) =>
|
||||
defineRouting({
|
||||
|
||||
Reference in new issue
Block a user