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