]>
Commit | Line | Data |
---|---|---|
63347a0f | 1 | import { Component, ElementRef, ViewChild } from '@angular/core' |
8afc19a6 | 2 | import { I18N_LOCALES } from '../../../../shared' |
63347a0f | 3 | import { NgbModal } from '@ng-bootstrap/ng-bootstrap' |
8afc19a6 C |
4 | |
5 | @Component({ | |
6 | selector: 'my-language-chooser', | |
7 | templateUrl: './language-chooser.component.html', | |
8 | styleUrls: [ './language-chooser.component.scss' ] | |
9 | }) | |
10 | export class LanguageChooserComponent { | |
63347a0f | 11 | @ViewChild('modal') modal: ElementRef |
8afc19a6 | 12 | |
63347a0f | 13 | languages: { id: string, label: string }[] = [] |
8afc19a6 | 14 | |
63347a0f | 15 | constructor (private modalService: NgbModal) { |
8afc19a6 C |
16 | this.languages = Object.keys(I18N_LOCALES) |
17 | .map(k => ({ id: k, label: I18N_LOCALES[k] })) | |
18 | } | |
19 | ||
20 | show () { | |
63347a0f | 21 | this.modalService.open(this.modal) |
8afc19a6 C |
22 | } |
23 | ||
24 | buildLanguageLink (lang: { id: string }) { | |
25 | return window.location.origin + '/' + lang.id | |
26 | } | |
27 | ||
28 | } |