Fix runtime default locale resolution
CI / quality (push) Waiting to run

This commit is contained in:
MOH
2026-03-15 06:02:27 +01:00
parent 9b8409a7d3
commit c18128c965
29 changed files with 330 additions and 108 deletions
+4 -3
View File
@@ -7,7 +7,7 @@ import { routing } from "@/i18n/routing";
import { getAdminAppPath, toInternalAdminPath } from "@/lib/admin-routing";
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
import { getLocalizedPath } from "@/lib/locale";
import { setMaintenanceMode } from "@/lib/app-config";
import { getSiteSettings, setMaintenanceMode } from "@/lib/app-config";
async function ensureAdmin() {
if (!(await isAdminAuthenticated())) {
@@ -33,10 +33,11 @@ export async function updateMaintenanceModeAction(formData: FormData) {
revalidatePath(toInternalAdminPath("/"));
revalidatePath(toInternalAdminPath("/maintenance"));
revalidatePath(toInternalAdminPath(redirectUrl.pathname));
const siteSettings = await getSiteSettings();
for (const appLocale of routing.locales) {
revalidatePath(getLocalizedPath(appLocale), "layout");
revalidatePath(getLocalizedPath(appLocale, "/coming-soon"));
revalidatePath(getLocalizedPath(appLocale, "/", siteSettings.defaultLocale), "layout");
revalidatePath(getLocalizedPath(appLocale, "/coming-soon", siteSettings.defaultLocale));
}
redirect(`${redirectUrl.pathname}${redirectUrl.search}`);
+4 -3
View File
@@ -6,7 +6,7 @@ import { isRedirectError } from "next/dist/client/components/redirect-error";
import { getAdminAppPath, toInternalAdminPath } from "@/lib/admin-routing";
import { clearAdminSessionCookie, isAdminAuthenticated } from "@/lib/admin-auth";
import { updateMarqueeSettings } from "@/lib/app-config";
import { getSiteSettings, updateMarqueeSettings } from "@/lib/app-config";
import { routing } from "@/i18n/routing";
import { getLocalizedPath } from "@/lib/locale";
@@ -27,10 +27,11 @@ function withMessage(pathname: string, type: "success" | "error", message: strin
async function revalidateMarqueePages() {
revalidatePath(toInternalAdminPath("/"));
revalidatePath(toInternalAdminPath("/marquee"));
const siteSettings = await getSiteSettings();
for (const locale of routing.locales) {
revalidatePath(getLocalizedPath(locale), "layout");
revalidatePath(getLocalizedPath(locale));
revalidatePath(getLocalizedPath(locale, "/", siteSettings.defaultLocale), "layout");
revalidatePath(getLocalizedPath(locale, "/", siteSettings.defaultLocale));
}
}
+7 -3
View File
@@ -16,6 +16,7 @@ import { removeManagedMediaFile } from "@/lib/media-storage";
import { mediaFieldInputSchema } from "@/lib/media-validation";
import { prisma } from "@/lib/prisma";
import { isCheckedFormValue } from "@/lib/form-data";
import { getSiteSettings } from "@/lib/app-config";
import {
assetInputSchema,
categoryInputSchema,
@@ -92,9 +93,10 @@ async function revalidatePortfolioPages() {
revalidatePath(toInternalAdminPath("/portfolio/categories"));
revalidatePath(toInternalAdminPath("/portfolio/projects"));
revalidatePath("/portfolio");
const siteSettings = await getSiteSettings();
for (const locale of routing.locales) {
revalidatePath(getLocalizedPath(locale, "/portfolio"));
revalidatePath(getLocalizedPath(locale, "/portfolio", siteSettings.defaultLocale));
}
}
@@ -520,9 +522,10 @@ export async function saveProjectAction(formData: FormData) {
await revalidatePortfolioPages();
revalidatePath(toInternalAdminPath(`/portfolio/projects/${projectResult.project.id}`));
revalidatePath(`/portfolio/${projectResult.project.slug}`);
const siteSettings = await getSiteSettings();
for (const locale of routing.locales) {
revalidatePath(getLocalizedPath(locale, `/portfolio/${projectResult.project.slug}`));
revalidatePath(getLocalizedPath(locale, `/portfolio/${projectResult.project.slug}`, siteSettings.defaultLocale));
}
redirect(
@@ -591,9 +594,10 @@ export async function deleteProjectAction(formData: FormData) {
await revalidatePortfolioPages();
revalidatePath(`/portfolio/${project.slug}`);
const siteSettings = await getSiteSettings();
for (const locale of routing.locales) {
revalidatePath(getLocalizedPath(locale, `/portfolio/${project.slug}`));
revalidatePath(getLocalizedPath(locale, `/portfolio/${project.slug}`, siteSettings.defaultLocale));
}
redirect(withMessage(getAdminAppPath("/portfolio"), "success", "Project deleted."));
+5 -5
View File
@@ -79,7 +79,7 @@ async function cleanupCreatedMedia(assetIds: string[], uploadedPaths: string[])
}
}
async function revalidateSiteSettingsPages() {
async function revalidateSiteSettingsPages(defaultLocale: SiteSettings["defaultLocale"]) {
revalidatePath("/", "layout");
revalidatePath(toInternalAdminPath("/"));
revalidatePath(toInternalAdminPath("/site-settings"));
@@ -88,10 +88,10 @@ async function revalidateSiteSettingsPages() {
const publicPaths = ["/", "/about", "/portfolio", "/contact", "/success", "/coming-soon"];
for (const locale of routing.locales) {
revalidatePath(getLocalizedPath(locale), "layout");
revalidatePath(getLocalizedPath(locale, "/", defaultLocale), "layout");
for (const path of publicPaths) {
revalidatePath(getLocalizedPath(locale, path));
revalidatePath(getLocalizedPath(locale, path, defaultLocale));
}
}
}
@@ -259,7 +259,7 @@ export async function saveSiteBrandSettingsAction(formData: FormData) {
],
});
await revalidateSiteSettingsPages();
await revalidateSiteSettingsPages(parsedSettings.defaultLocale);
redirect(withMessage(getAdminAppPath("/site-settings/brand"), "success", "Einstellungen gespeichert."));
} catch (error) {
if (isRedirectError(error)) {
@@ -321,7 +321,7 @@ export async function saveSiteLocalizationSettingsAction(formData: FormData) {
}
await updateSiteSettings(parsedSettings);
await revalidateSiteSettingsPages();
await revalidateSiteSettingsPages(parsedSettings.defaultLocale);
redirect(withMessage(getAdminAppPath("/site-settings/localization"), "success", "Einstellungen gespeichert."));
} catch (error) {
if (isRedirectError(error)) {