refactor(dashboard): apply new i18n resolver to dashboard shell and localized fields

This commit is contained in:
poyrazavsever
2026-07-20 10:25:40 +03:00
parent 7a4f2bf2ea
commit 763c243962
5 changed files with 24 additions and 9 deletions
+2 -2
View File
@@ -2,7 +2,7 @@ import { DashboardShell } from "@/components/layout/dashboard-shell";
import { domainActorFromSession } from "@/server/auth/domain-actor"; import { domainActorFromSession } from "@/server/auth/domain-actor";
import { requireFreelancer } from "@/server/auth/session"; import { requireFreelancer } from "@/server/auth/session";
import { getPublicBranding } from "@/server/branding/runtime"; import { getPublicBranding } from "@/server/branding/runtime";
import { resolveRequestLocale } from "@/server/i18n/resolver"; import { resolveFreelancerLocale } from "@/server/i18n/resolver";
import { createTranslator, getClientI18nPayload } from "@/server/i18n/translator"; import { createTranslator, getClientI18nPayload } from "@/server/i18n/translator";
import { getUserPreferences } from "@/server/settings/preferences"; import { getUserPreferences } from "@/server/settings/preferences";
@@ -15,7 +15,7 @@ export default async function DashboardLayout({
const { user, profile } = context; const { user, profile } = context;
const branding = getPublicBranding(); const branding = getPublicBranding();
const preferences = getUserPreferences(domainActorFromSession(context)); const preferences = getUserPreferences(domainActorFromSession(context));
const resolvedLocale = await resolveRequestLocale(); const resolvedLocale = await resolveFreelancerLocale(context);
const translator = createTranslator(resolvedLocale.locale, [ const translator = createTranslator(resolvedLocale.locale, [
"common", "common",
"navigation", "navigation",
+2 -2
View File
@@ -9,7 +9,7 @@ import {
} from "@/lib/color-mode"; } from "@/lib/color-mode";
import { Toaster } from "poyraz-ui/molecules"; import { Toaster } from "poyraz-ui/molecules";
import { getPublicBranding } from "@/server/branding/runtime"; import { getPublicBranding } from "@/server/branding/runtime";
import { resolveRequestLocale } from "@/server/i18n/resolver"; import { resolveRootLocale } from "@/server/i18n/resolver";
const colorModeScript = `(() => { const colorModeScript = `(() => {
const root = document.documentElement; const root = document.documentElement;
@@ -53,7 +53,7 @@ export default async function RootLayout({
const colorMode = isColorMode(cookieColorMode) const colorMode = isColorMode(cookieColorMode)
? cookieColorMode ? cookieColorMode
: branding.defaultColorMode; : branding.defaultColorMode;
const locale = await resolveRequestLocale(); const locale = await resolveRootLocale();
return ( return (
<html <html
+2 -2
View File
@@ -1,11 +1,11 @@
import { getPublicBranding } from "@/server/branding/runtime"; import { getPublicBranding } from "@/server/branding/runtime";
import { resolveRequestLocale } from "@/server/i18n/resolver"; import { resolveRootLocale } from "@/server/i18n/resolver";
import { createTranslator } from "@/server/i18n/translator"; import { createTranslator } from "@/server/i18n/translator";
import Link from "next/link"; import Link from "next/link";
import { Button, Typography } from "poyraz-ui/atoms"; import { Button, Typography } from "poyraz-ui/atoms";
export default async function NotFoundPage() { export default async function NotFoundPage() {
const locale = await resolveRequestLocale(); const locale = await resolveRootLocale();
const t = createTranslator(locale.locale, ["common"]).t; const t = createTranslator(locale.locale, ["common"]).t;
const branding = getPublicBranding(); const branding = getPublicBranding();
+17 -2
View File
@@ -19,6 +19,10 @@ type LocalizedFieldsProps = {
fields: ContentTranslationField[]; fields: ContentTranslationField[];
values?: LocalizedFieldValues | null; values?: LocalizedFieldValues | null;
fallbackValues?: Record<string, string | null | undefined>; fallbackValues?: Record<string, string | null | undefined>;
labels?: {
defaultBadge?: string;
missingRequired?: string;
};
}; };
export function LocalizedFields({ export function LocalizedFields({
@@ -28,6 +32,7 @@ export function LocalizedFields({
fields, fields,
values, values,
fallbackValues, fallbackValues,
labels,
}: LocalizedFieldsProps) { }: LocalizedFieldsProps) {
const orderedLocales = useMemo(() => { const orderedLocales = useMemo(() => {
const localeMap = new Map(locales.map((locale) => [locale.code, locale])); const localeMap = new Map(locales.map((locale) => [locale.code, locale]));
@@ -66,8 +71,18 @@ export function LocalizedFields({
onClick={() => setActiveLocale(locale.code)} onClick={() => setActiveLocale(locale.code)}
> >
{locale.nativeName || locale.code} {locale.nativeName || locale.code}
{locale.code === defaultLocale ? <Badge variant="secondary">varsayılan</Badge> : null} {locale.code === defaultLocale ? (
{missingRequiredLocales.has(locale.code) ? <span aria-hidden="true" className="text-amber-500"></span> : null} <Badge variant="secondary">{labels?.defaultBadge ?? "Default"}</Badge>
) : null}
{missingRequiredLocales.has(locale.code) ? (
<span
aria-label={labels?.missingRequired}
aria-hidden={labels?.missingRequired ? undefined : true}
className="text-amber-500"
>
</span>
) : null}
</Button> </Button>
))} ))}
</div> </div>
+1 -1
View File
@@ -35,7 +35,7 @@ export function DashboardShell({ branding, children, colorMode, i18n, labels, us
homeHref="/" homeHref="/"
labels={labels} labels={labels}
navGroups={navGroups} navGroups={navGroups}
settingsHref="/settings" settingsHref="/settings/general"
user={user} user={user}
> >
{children} {children}