perf(proxy): isolate settings database reads

This commit is contained in:
ajnart committed 2026-07-29 06:47:07 +02:00
1 parent add6ee56ba
commit f8d8a09c56
17 files changed
+604 -18

No files matched your search

+5 -5
View File
@@ -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;
+2 -2
View File
@@ -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]);
});
});
+46
View File
@@ -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 -1
View File
@@ -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) =>
+3 -3
View File
@@ -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({