Skip to content
Snippets Groups Projects
Commit 725ed4b2 authored by Samuel Eickelberg's avatar Samuel Eickelberg
Browse files

OP#17449 Added calling the current user language in dcc-localised-string.component.ts

parent 33bd83cc
Branches
Tags 0.0.4
No related merge requests found
Pipeline #57828 failed
<div *ngFor="let item of strings.content; let i = index">
<ng-container *ngIf="getOrSetLang(item)">
<mat-form-field class="custom-form-field">
<mat-label>{{placeholder}}</mat-label>
<input [(ngModel)]="item.text" [required]=" isRequired " matInput name="item"/>
......
import { Component, Input, OnInit, ChangeDetectorRef, AfterContentChecked } from '@angular/core';
import { LanguageSpecificStringsDto } from 'src/app/generated/dcc/model/languageSpecificStringsDto';
import { LangTextPair } from 'src/app/generated/dcc/model/langTextPair';
import { NavigationComponent } from '../../common/navigation/navigation.component';
@Component({
selector: 'app-dcc-localised-string',
......@@ -16,22 +18,19 @@ export class DccLocalisedStringComponent implements OnInit, AfterContentChecked
locales = [
{ lang: "de", name: "Deutsch", icon: "fi fi-de" },
{ lang: "en", name: "Englisch", icon: "fi fi-us" },
{ lang: "fr", name: "Französisch", icon: "fi fi-fr" },
{ lang: "es", name: "Spanisch", icon: "fi fi-es" }
{ lang: "en", name: "English", icon: "fi fi-us" },
{ lang: "fr", name: "Français", icon: "fi fi-fr" },
{ lang: "es", name: "Español", icon: "fi fi-es" }
];
languageMap = new Map<string, any>();
// lang:string='';
// text:string='';
constructor(private cdref: ChangeDetectorRef) {
constructor(private cdref: ChangeDetectorRef, private navigation: NavigationComponent) {
this.strings = <LanguageSpecificStringsDto>{};
this.placeholder = "";
}
ngOnInit(): void {
if (!this.strings) {
this.strings = this.getEmptyStringWithLangDto();
}
......@@ -39,12 +38,10 @@ export class DccLocalisedStringComponent implements OnInit, AfterContentChecked
}
ngAfterContentChecked() {
// console.log('strings',this.strings)
this.cdref.detectChanges();
}
initializeLanguageMap() {
this.languageMap.clear();
if (this.strings.content) {
this.strings.content!.forEach(item => {
......@@ -64,7 +61,6 @@ export class DccLocalisedStringComponent implements OnInit, AfterContentChecked
preselected.text = this.placeholder;
result.content.push(preselected)
return result;
}
getEmptyStringWithLangText(): LangTextPair {
......@@ -86,9 +82,8 @@ export class DccLocalisedStringComponent implements OnInit, AfterContentChecked
}
getOrSetLang(item: any): string {
if (item.lang === '**' || item.lang === undefined) {
item.lang = 'de';
item.lang = this.navigation.getUserLanguage();
}
return item.lang;
}
......
......@@ -2,7 +2,7 @@
<h3 i18n>{{'mathml.formula' | translate}}</h3>
<mat-form-field class="flex-item">
<textarea [(ngModel)]="mathml" class="custom-textarea" id="mathml" matInput name="mathml"
placeholder="{{'mathml.yourmathMlExpressionHere' | translate}}"></textarea>
placeholder="'mathml.yourmathMlExpressionHere' | translate"></textarea>
</mat-form-field>
<div #mathContainer style="padding-bottom: 10px;"></div>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment