Track HiveGrid Cloud planning reference

This commit is contained in:
david committed 2026-06-26 20:48:01 +02:00
1 parent b3d5ea6764
commit e341c5938a
5784 files changed
+1104929 -3

No files matched your search

@@ -0,0 +1,34 @@
// ============================================
// Site Settings Utilities
// Helper functions for copy configuration
// ============================================
import { getSiteType } from "../site-types";
type SiteCopyTranslator = (key: string) => string;
export function getSiteCopyFallbackKey(type: string, key: string): string {
return `models.site.types.${type}.copy.${key}.fallback`;
}
function resolveCopyFallback(type: string, key: string, fallback: string, t?: SiteCopyTranslator): string {
if (!t) return fallback;
const fallbackKey = getSiteCopyFallbackKey(type, key);
const translated = t(fallbackKey);
return translated === fallbackKey ? fallback : translated;
}
/**
* Build copy object with fallback values for missing keys
*/
export function buildCopyWithFallbacks(type: string, savedCopy: Record<string, string> | null, t?: SiteCopyTranslator): Record<string, string> {
const siteType = getSiteType(type);
if (!siteType) return {};
const result: Record<string, string> = {};
for (const { key, fallback } of siteType.copyKeys) {
result[key] = savedCopy?.[key] || resolveCopyFallback(type, key, fallback, t);
}
return result;
}