Commit 65603e5e authored by Romain DELEAU's avatar Romain DELEAU

change language button/menu

parent 195e9ef8
...@@ -152,12 +152,16 @@ ...@@ -152,12 +152,16 @@
<input type="file" #fileInput style="display: none" (change)="onFileSelected($event)"> <input type="file" #fileInput style="display: none" (change)="onFileSelected($event)">
</div> </div>
<div class="container-settings container-settings-secondline"> <div class="container-settings container-settings-secondline">
<button mat-mini-fab color="white" style="font-size: 20px;" [matMenuTriggerFor]="changeLanguageMenu"
[matTooltip]="translate.instant('lang_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">{{langEmoji}}</button>
<mat-menu #changeLanguageMenu="matMenu">
<button mat-menu-item (click)="changeLanguage('fr')">🇫🇷 {{'language_fr' | translate}}</button>
<button mat-menu-item (click)="changeLanguage('en')">🇬🇧 {{'language_en' | translate}}</button>
</mat-menu>
<button mat-mini-fab color="white" (click)="downloadManual()" <button mat-mini-fab color="white" (click)="downloadManual()"
[matTooltip]="translate.instant('manual_tooltip')" [matTooltip]="translate.instant('manual_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"><mat-icon fontIcon="menu_book"></mat-icon></button> matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips"><mat-icon fontIcon="menu_book"></mat-icon></button>
<button mat-mini-fab color="white" (click)="changeLanguage()"
[matTooltip]="translate.instant('lang_tooltip')"
matTooltipPosition="above" [matTooltipDisabled]="!tooltipService.activatedTooltips">🇫🇷</button>
</div> </div>
<div class="container-minimap"></div> <div class="container-minimap"></div>
<div class="container-zoom"> <div class="container-zoom">
......
...@@ -197,8 +197,9 @@ ...@@ -197,8 +197,9 @@
} }
&-secondline { &-secondline {
width: 50px;
top: 75px; top: 75px;
width: 112px;
right: 360px;
} }
} }
......
...@@ -48,6 +48,7 @@ export class AppComponent { ...@@ -48,6 +48,7 @@ export class AppComponent {
scenario: Scenario = new Scenario(); scenario: Scenario = new Scenario();
@ViewChild('fileInput') fileInput: any; @ViewChild('fileInput') fileInput: any;
selectedLang: string = 'en'; selectedLang: string = 'en';
langEmoji: string = '🇬🇧';
constructor(private cdr: ChangeDetectorRef, private http: HttpClient, protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService, constructor(private cdr: ChangeDetectorRef, private http: HttpClient, protected pieceDetailsService: PieceDetailsService, protected tooltipService: TooltipService,
private elementRef: ElementRef, private zoomService: ZoomService, private dialog: MatDialog, private titleService: Title, private elementRef: ElementRef, private zoomService: ZoomService, private dialog: MatDialog, private titleService: Title,
...@@ -63,6 +64,10 @@ export class AppComponent { ...@@ -63,6 +64,10 @@ export class AppComponent {
this.selectedLang = selectedLang; this.selectedLang = selectedLang;
} }
translate.use(this.selectedLang); translate.use(this.selectedLang);
switch(selectedLang) {
case 'en': this.langEmoji = '🇬🇧'; break;
case 'fr': this.langEmoji = '🇫🇷'; break;
}
pieceDetailsService.piece = this.scenario; pieceDetailsService.piece = this.scenario;
...@@ -114,15 +119,15 @@ export class AppComponent { ...@@ -114,15 +119,15 @@ export class AppComponent {
} }
} }
changeLanguage(): void { changeLanguage(lang: string): void {
if (this.selectedLang == 'en') { if (lang !== this.selectedLang) {
this.selectedLang = 'fr'; switch(lang) {
this.translate.use('fr'); case 'fr': this.selectedLang = 'fr'; this.translate.use('fr'); this.langEmoji = '🇫🇷'; break;
} else if (this.selectedLang == 'fr') { case 'en': this.selectedLang = 'en'; this.translate.use('en'); this.langEmoji = '🇬🇧'; break;
this.selectedLang = 'en'; }
this.translate.use('en'); this.minimapService.reset();
this.scenario.traces.push(new Trace(this.scenario.traces.length, 'change_lang', undefined, undefined, 'all', 'Scenario'));
} }
this.minimapService.reset();
} }
downloadManual(): void { downloadManual(): void {
......
{ {
"language_fr": "French",
"language_en": "English",
"clearPiece_tooltip": "Clear the content of this tile.", "clearPiece_tooltip": "Clear the content of this tile.",
"deletePiece_tooltip": "Delete the tile", "deletePiece_tooltip": "Delete the tile",
"moveRight_tooltip": "Shift the tile to the right. In case a tile is already present, their positions are swapped.", "moveRight_tooltip": "Shift the tile to the right. In case a tile is already present, their positions are swapped.",
......
{ {
"language_fr": "Français",
"language_en": "Anglais",
"clearPiece_tooltip": "Effacer le contenu de cette tuile", "clearPiece_tooltip": "Effacer le contenu de cette tuile",
"deletePiece_tooltip": "Supprimer la tuile", "deletePiece_tooltip": "Supprimer la tuile",
"moveRight_tooltip": "Décaler la tuile vers la droite. Dans le cas où une tuile est déjà présente, leurs places sont inversées.", "moveRight_tooltip": "Décaler la tuile vers la droite. Dans le cas où une tuile est déjà présente, leurs places sont inversées.",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment