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
+16 -6
View File
@@ -6,8 +6,9 @@ import { Container } from "@/components/layout/container";
import { PageHero } from "@/components/layout/page-hero";
import { PortfolioCategoryFilter } from "@/components/site/portfolio-category-filter";
import { PortfolioProjectGrid } from "@/components/site/portfolio-project-grid";
import { getSiteSettings } from "@/lib/app-config";
import { buildLocalizedMetadata } from "@/lib/metadata";
import { getLocalizedPath, resolveLocale } from "@/lib/locale";
import { FALLBACK_LOCALE, getLocalizedPath, resolveLocale } from "@/lib/locale";
import { getActivePortfolioCategories, getPublishedPortfolioProjects } from "@/lib/portfolio";
type PortfolioPageProps = {
@@ -23,7 +24,7 @@ export const dynamic = "force-dynamic";
export async function generateMetadata({ params }: PortfolioPageProps): Promise<Metadata> {
const { locale } = await params;
const localeKey = resolveLocale(locale);
const localeKey = resolveLocale(locale, FALLBACK_LOCALE);
const t = await getTranslations({ locale: localeKey, namespace: "portfolioPage" });
return await buildLocalizedMetadata({
@@ -42,12 +43,15 @@ export default async function PortfolioPage({
params,
searchParams,
]);
const localeKey = resolveLocale(locale);
const t = await getTranslations({ locale: localeKey, namespace: "portfolioPage" });
const localeKey = resolveLocale(locale, FALLBACK_LOCALE);
const [t, siteSettings] = await Promise.all([
getTranslations({ locale: localeKey, namespace: "portfolioPage" }),
getSiteSettings(),
]);
const selectedCategory = resolvedSearchParams?.category ?? "";
if (selectedCategory) {
redirect(getLocalizedPath(localeKey, `/portfolio/category/${selectedCategory}`));
redirect(getLocalizedPath(localeKey, `/portfolio/category/${selectedCategory}`, siteSettings.defaultLocale));
}
const [categories, projects] = await Promise.all([
@@ -65,9 +69,15 @@ export default async function PortfolioPage({
/>
<Container className="flex flex-col gap-section pb-12 lg:pb-16">
<PortfolioCategoryFilter locale={localeKey} categories={categories} allLabel={t("all")} />
<PortfolioCategoryFilter
locale={localeKey}
defaultLocale={siteSettings.defaultLocale}
categories={categories}
allLabel={t("all")}
/>
<PortfolioProjectGrid
locale={localeKey}
defaultLocale={siteSettings.defaultLocale}
projects={projects}
emptyLabel={t("empty")}
openLabel={t("open")}