fix: parse raw public translation responses in banner
Some checks failed
CI / Banner Lint & 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 / Banner Tests (push) Has been cancelled
CI / Banner Build (push) Has been cancelled
CI / Admin UI Typecheck (push) Has been cancelled
CI / Admin UI Tests (push) Has been cancelled
CI / Admin UI Build (push) Has been cancelled
Some checks failed
CI / Banner Lint & 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 / Banner Tests (push) Has been cancelled
CI / Banner Build (push) Has been cancelled
CI / Admin UI Typecheck (push) Has been cancelled
CI / Admin UI Tests (push) Has been cancelled
CI / Admin UI Build (push) Has been cancelled
The public translations endpoint returns the raw strings dictionary, but
the banner expected a wrapped { strings } response and therefore fell back
to English for Thai translations.
Update fetchTranslations() to accept the raw public API shape while keeping
compatibility with wrapped responses. Make default_language optional in the
banner SiteConfig type so old/mocked configs still typecheck.
This commit is contained in:
@@ -95,9 +95,10 @@ export async function fetchTranslations(
|
||||
try {
|
||||
const resp = await fetch(`${apiBase}/api/v1/translations/${siteId}/${locale}`);
|
||||
if (!resp.ok) return null;
|
||||
// API returns { strings: { ... } }
|
||||
const data = (await resp.json()) as { strings?: Partial<TranslationStrings> };
|
||||
return data.strings ?? null;
|
||||
// Public API returns the raw strings dict. Accept a wrapped `{ strings }`
|
||||
// shape too for backwards compatibility with older mocks/clients.
|
||||
const data = await resp.json() as Partial<TranslationStrings> | { strings?: Partial<TranslationStrings> };
|
||||
return 'strings' in data && data.strings ? data.strings : data as Partial<TranslationStrings>;
|
||||
} catch {
|
||||
return null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user