fix(general): route supported-languages field through LocaleSyncService, guard unsupported default locale
Some checks failed
Architecture Governance / architecture (push) Has been cancelled
Some checks failed
Architecture Governance / architecture (push) Has been cancelled
General's free-text 'Supported Languages' field overwrote tenant/localization.supportedLocales directly, skipping LocaleSyncService's propagation to per-locale nav/static-page translation entries - the exact sync Languages' add/remove buttons already go through correctly. Now diffs against the current list and routes each added/removed locale through facade.addLocale()/removeLocale(). Also: 'Default Language' was a free-text input with no guard against typing a locale that isn't in the supported list - every label[defaultLocale] lookup across nav/static-page content would then silently return undefined. Added a validator rule (default-locale-not-supported) wired to the existing fieldError() display, consistent with every other field-level check. Verified live via window.ng.getComponent(): typing an unsupported code shows the new inline error; adding 'de' via this field seeded an empty 'de' translation entry on an existing static page, matching what Languages' add-locale button already produces. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
@@ -61,12 +61,25 @@ export class ProjectEditorGeneralSectionComponent {
|
||||
}));
|
||||
}
|
||||
|
||||
/**
|
||||
* Routes through facade.addLocale()/removeLocale() (LocaleSyncService)
|
||||
* instead of overwriting supportedLocales directly - a direct overwrite
|
||||
* skipped seeding/cleaning up per-locale nav and static-page translation
|
||||
* entries, leaving them out of sync with what this field claims is
|
||||
* supported (and Languages' add/remove buttons already do it correctly).
|
||||
*/
|
||||
updateSupportedLanguages(value: string): void {
|
||||
const locales = value.split(',').map(item => item.trim()).filter(Boolean);
|
||||
this.facade.updateBootstrap(current => ({
|
||||
...current,
|
||||
tenant: { ...current.tenant, supportedLocales: locales },
|
||||
localization: { ...current.localization, supportedLocales: locales }
|
||||
}));
|
||||
const next = new Set(value.split(',').map(item => item.trim().toLowerCase()).filter(Boolean));
|
||||
const current = this.bootstrap()?.localization.supportedLocales ?? [];
|
||||
for (const locale of current) {
|
||||
if (!next.has(locale)) {
|
||||
this.facade.removeLocale(locale);
|
||||
}
|
||||
}
|
||||
for (const locale of next) {
|
||||
if (!current.includes(locale)) {
|
||||
this.facade.addLocale(locale);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user