feat(i18n): migrate route structure under [locale] parameter prefix
This commit is contained in:
@@ -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;
|
||||
}
|
||||
Reference in New Issue
Block a user