Skip to content

Commit

Permalink
feat(Multiple Languages): Show current language in TranslatableInput'…
Browse files Browse the repository at this point in the history
…s label (#1588)

This helps the translator know to type the translation for the currently-selected language.
  • Loading branch information
hirokiterashima authored Jan 25, 2024
1 parent eafbb37 commit 89b5cd9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<ng-content *ngIf="!showTranslationInput()"></ng-content>
<mat-form-field *ngIf="showTranslationInput()">
<mat-label i18n>{{ defaultLanguageLabelRef.nativeElement.innerHTML }}</mat-label>
<mat-label
>{{ defaultLanguageLabelRef.nativeElement.innerHTML }} ({{
currentLanguage().language
}})</mat-label
>
<input
matInput
[ngModel]="translatedText()"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { MatInput, MatInputModule } from '@angular/material/input';
import { FormsModule } from '@angular/forms';
import { TranslateProjectService } from '../../../services/translateProjectService';
import { MatLabel } from '@angular/material/form-field';
import { Language } from '../../../../../app/domain/language';

@Component({
standalone: true,
Expand All @@ -15,6 +16,7 @@ import { MatLabel } from '@angular/material/form-field';
})
export class TranslatableInputComponent {
@Input() content: object;
protected currentLanguage: Signal<Language>;
@ContentChild(MatInput) defaultLanguageInput: MatInput;
@ContentChild(MatLabel, { read: ElementRef }) defaultLanguageLabelRef: ElementRef;
protected defaultLanguageText: Signal<string>;
Expand All @@ -26,6 +28,7 @@ export class TranslatableInputComponent {
private projectService: TeacherProjectService,
private translateProjectService: TranslateProjectService
) {
this.currentLanguage = projectService.currentLanguage;
this.showTranslationInput = computed(() => !this.projectService.isDefaultLocale());
}

Expand Down
9 changes: 1 addition & 8 deletions src/messages.xlf
Original file line number Diff line number Diff line change
Expand Up @@ -10123,18 +10123,11 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
<context context-type="linenumber">75</context>
</context-group>
</trans-unit>
<trans-unit id="7bd83cfa9e268b699d003e1b37b428995d29fc27" datatype="html">
<source><x id="INTERPOLATION" equiv-text="{{ defaultLanguageLabelRef.nativeElement.innerHTML }}"/></source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/components/translatable-input/translatable-input.component.html</context>
<context context-type="linenumber">3</context>
</context-group>
</trans-unit>
<trans-unit id="4565494938772544139" datatype="html">
<source>(<x id="PH" equiv-text="this.projectService.getLocale().getDefaultLanguage().language"/>: <x id="PH_1" equiv-text="this.content[this.key]"/>)</source>
<context-group purpose="location">
<context context-type="sourcefile">src/assets/wise5/authoringTool/components/translatable-input/translatable-input.component.ts</context>
<context context-type="linenumber">41,43</context>
<context context-type="linenumber">44,46</context>
</context-group>
</trans-unit>
<trans-unit id="1318680729593701201" datatype="html">
Expand Down

0 comments on commit 89b5cd9

Please sign in to comment.