fix(general): route supported-languages field through LocaleSyncService, guard unsupported default locale
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:
sdarbinyan
2026-07-17 19:00:17 +04:00
parent 2e683cc872
commit 76e9689e11
7 changed files with 35 additions and 10 deletions

View File

@@ -70,9 +70,17 @@ export class ProjectValidator {
}
private languageIssues(bootstrap: BootstrapConfig): ProjectValidationIssue[] {
return bootstrap.localization.supportedLocales.length > 0
? []
: [error('no-languages', 'builder.validationNoLanguages', 'languages', 'localization.supportedLocales')];
if (bootstrap.localization.supportedLocales.length === 0) {
return [error('no-languages', 'builder.validationNoLanguages', 'languages', 'localization.supportedLocales')];
}
// General's free-text "Default Language" field (unlike Languages' set-default
// buttons, which only ever target an already-supported locale) can set this
// to any string. A default locale that isn't itself supported breaks every
// `label[defaultLocale]` lookup across nav/static-page content.
if (!bootstrap.localization.supportedLocales.includes(bootstrap.localization.defaultLocale)) {
return [error('default-locale-not-supported', 'builder.validationDefaultLocaleNotSupported', 'general', 'localization.defaultLocale')];
}
return [];
}
private urlIssues(bootstrap: BootstrapConfig): ProjectValidationIssue[] {