fix(languages): show error instead of silently no-oping when adding a duplicate locale
Some checks failed
Architecture Governance / architecture (push) Has been cancelled

addLocale() always cleared the input, even when LocaleSyncService rejected
the code because it was already supported - same silent-failure shape as
the widgets JSON bug fixed earlier this session. Now checks locales()
first and shows an inline error, leaving the input untouched, instead of
clearing it like the add succeeded. Verified live: typing an existing
locale code and clicking Add now shows 'This language is already supported.'

Navigation-section was also audited (id generation, label locale-migration,
reorder swap, grouped-footer read-only fallback) - no defects found, it's
solid as-is.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
sdarbinyan
2026-07-17 18:31:01 +04:00
parent 3839e2e1f6
commit 2417a7795b
6 changed files with 20 additions and 2 deletions

View File

@@ -37,15 +37,25 @@ export class ProjectEditorLanguagesSectionComponent {
updateNewLocale(value: string): void {
this.newLocale.set(value);
if (this.addLocaleError()) {
this.addLocaleError.set(null);
}
}
readonly addLocaleError = signal<string | null>(null);
addLocale(): void {
const code = this.newLocale().trim();
const code = this.newLocale().trim().toLowerCase();
if (!code) {
return;
}
if (this.locales().includes(code)) {
this.addLocaleError.set(this.translate.t('builder.languageAlreadyAdded'));
return;
}
this.facade.addLocale(code);
this.newLocale.set('');
this.addLocaleError.set(null);
}
removeLocale(code: string): void {