feat(project-editor): add Languages tab with generic locale sync

This commit is contained in:
sdarbinyan
2026-07-13 08:10:00 +04:00
parent 74e5099b04
commit b166920ad7
12 changed files with 237 additions and 1 deletions

View File

@@ -0,0 +1,33 @@
<section class="editor-section-card">
<div class="editor-actions">
<h2>{{ 'builder.languagesTab' | translate }}</h2>
</div>
<div class="editor-actions">
<input
type="text"
[ngModel]="newLocale()"
(ngModelChange)="updateNewLocale($event)"
placeholder="de"
/>
<button type="button" (click)="addLocale()">{{ 'builder.addLanguage' | translate }}</button>
</div>
<div class="stack-list">
@for (code of locales(); track code) {
<article class="sub-card">
<div class="editor-actions">
<h3>{{ code }}</h3>
<div class="editor-actions">
@if (code === defaultLocale()) {
<span>{{ 'builder.defaultLanguageLabel' | translate }}</span>
} @else {
<button type="button" class="secondary" (click)="setDefault(code)">{{ 'builder.setDefaultLanguage' | translate }}</button>
<button type="button" class="secondary" (click)="removeLocale(code)">{{ 'builder.removeLanguage' | translate }}</button>
}
</div>
</div>
</article>
}
</div>
</section>

View File

@@ -0,0 +1,41 @@
import { ChangeDetectionStrategy, Component, computed, inject, signal } from '@angular/core';
import { FormsModule } from '@angular/forms';
import { ProjectEditorFacade } from '../facade/project-editor.facade';
import { TranslatePipe } from '../../../i18n/translate.pipe';
@Component({
selector: 'app-project-editor-languages-section',
standalone: true,
imports: [FormsModule, TranslatePipe],
templateUrl: './languages-section.component.html',
styleUrls: ['./section.shared.scss'],
changeDetection: ChangeDetectionStrategy.OnPush
})
export class ProjectEditorLanguagesSectionComponent {
private readonly facade = inject(ProjectEditorFacade);
readonly bootstrap = this.facade.bootstrap;
readonly locales = computed(() => this.bootstrap()?.localization.supportedLocales ?? []);
readonly defaultLocale = computed(() => this.bootstrap()?.localization.defaultLocale ?? '');
readonly newLocale = signal('');
updateNewLocale(value: string): void {
this.newLocale.set(value);
}
addLocale(): void {
const code = this.newLocale().trim();
if (!code) {
return;
}
this.facade.addLocale(code);
this.newLocale.set('');
}
removeLocale(code: string): void {
this.facade.removeLocale(code);
}
setDefault(code: string): void {
this.facade.setDefaultLocale(code);
}
}