feat: add default_language to site config for banner i18n
Some checks failed
CI / Banner Lint & Typecheck (push) Has been cancelled
CI / Banner Tests (push) Has been cancelled
CI / Banner Build (push) Has been cancelled
CI / Admin UI Typecheck (push) Has been cancelled
CI / Detect changes (push) Has been cancelled
CI / API Lint (push) Has been cancelled
CI / API Tests (push) Has been cancelled
CI / Scanner Lint (push) Has been cancelled
CI / Scanner Tests (push) Has been cancelled
CI / Admin UI Tests (push) Has been cancelled
CI / Admin UI Build (push) Has been cancelled

Site owners can now set a default language for the consent banner,
overriding browser auto-detection. When null the banner uses
navigator.language / data-locale as before (existing behaviour).

Changes:
- DB: add default_language column to site_configs (nullable, String(10))
- API model: SiteConfig.default_language field
- API schema: SiteConfigCreate/Update/Response schemas
- Config resolver: pass default_language through to public config
- Banner types: SiteConfig.default_language field
- Banner logic: use config.default_language ?? detectLocale()
- Admin UI: SiteConfigTab dropdown with auto-detect option
- Admin UI types: SiteConfig.default_language added
This commit is contained in:
Kunthawat Greethong
2026-06-15 18:11:39 +07:00
parent 2757cd9e46
commit e9bae32ee2
8 changed files with 82 additions and 1 deletions

View File

@@ -220,7 +220,8 @@ async function init(): Promise<void> {
}
// Load translations
const locale = detectLocale();
// Use site-configured default_language if set, otherwise auto-detect
const locale = config.default_language ?? detectLocale();
const t = await loadTranslations(cdnBase, locale);
// Capture a closure that re-opens the banner with current consent

View File

@@ -80,6 +80,7 @@ export interface SiteConfig {
gcm_default: Record<string, 'granted' | 'denied'> | null;
shopify_privacy_enabled: boolean;
banner_config: BannerConfig | null;
default_language: string | null;
privacy_policy_url: string | null;
terms_url: string | null;
consent_expiry_days: number;