Replace entire repo content with correct code from /root/shahikitchen-website/
This commit is contained in:
@@ -0,0 +1,30 @@
|
||||
/** Shallow-deep merge for translation fallbacks */
|
||||
export function mergeTranslations<T extends Record<string, unknown>>(
|
||||
base: T,
|
||||
override: Partial<T>
|
||||
): T {
|
||||
const result = { ...base };
|
||||
|
||||
for (const key of Object.keys(override) as (keyof T)[]) {
|
||||
const baseVal = base[key];
|
||||
const overrideVal = override[key];
|
||||
|
||||
if (
|
||||
overrideVal &&
|
||||
typeof overrideVal === 'object' &&
|
||||
!Array.isArray(overrideVal) &&
|
||||
baseVal &&
|
||||
typeof baseVal === 'object' &&
|
||||
!Array.isArray(baseVal)
|
||||
) {
|
||||
result[key] = mergeTranslations(
|
||||
baseVal as Record<string, unknown>,
|
||||
overrideVal as Record<string, unknown>
|
||||
) as T[keyof T];
|
||||
} else if (overrideVal !== undefined) {
|
||||
result[key] = overrideVal as T[keyof T];
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user