feat(i18n): migrate route structure under [locale] parameter prefix

This commit is contained in:
Poyraz
2026-06-27 14:42:42 +03:00
parent 968ebb33c5
commit d3c56713fb
3 changed files with 163 additions and 0 deletions
+15
View File
@@ -0,0 +1,15 @@
export type Localized<T = string> = {
tr: T;
en: T;
};
export function getLocalizedValue<T>(
value: Localized<T> | T | string,
locale: string
): T {
if (value && typeof value === "object" && ("tr" in value || "en" in value)) {
const localizedObj = value as Record<string, T>;
return localizedObj[locale] || localizedObj["tr"];
}
return value as T;
}