]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/menu/language-chooser.component.ts
Add ability to choose the language
[github/Chocobozzz/PeerTube.git] / client / src / app / menu / language-chooser.component.ts
CommitLineData
8afc19a6
C
1import { Component, ViewChild } from '@angular/core'
2import { ModalDirective } from 'ngx-bootstrap/modal'
3import { I18N_LOCALES } from '../../../../shared'
4
5@Component({
6 selector: 'my-language-chooser',
7 templateUrl: './language-chooser.component.html',
8 styleUrls: [ './language-chooser.component.scss' ]
9})
10export class LanguageChooserComponent {
11 @ViewChild('modal') modal: ModalDirective
12
13 languages: { [ id: string ]: string }[] = []
14
15 constructor () {
16 this.languages = Object.keys(I18N_LOCALES)
17 .map(k => ({ id: k, label: I18N_LOCALES[k] }))
18 }
19
20 show () {
21 this.modal.show()
22 }
23
24 hide () {
25 this.modal.hide()
26 }
27
28 buildLanguageLink (lang: { id: string }) {
29 return window.location.origin + '/' + lang.id
30 }
31
32}