]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/menu/language-chooser.component.ts
Add portuguese and swedish languages
[github/Chocobozzz/PeerTube.git] / client / src / app / menu / language-chooser.component.ts
1 import { Component, ElementRef, ViewChild } from '@angular/core'
2 import { I18N_LOCALES } from '../../../../shared'
3 import { NgbModal } from '@ng-bootstrap/ng-bootstrap'
4 import { sortBy } from '@app/shared/misc/utils'
5
6 @Component({
7 selector: 'my-language-chooser',
8 templateUrl: './language-chooser.component.html',
9 styleUrls: [ './language-chooser.component.scss' ]
10 })
11 export class LanguageChooserComponent {
12 @ViewChild('modal') modal: ElementRef
13
14 languages: { id: string, label: string }[] = []
15
16 constructor (private modalService: NgbModal) {
17 const l = Object.keys(I18N_LOCALES)
18 .map(k => ({ id: k, label: I18N_LOCALES[k] }))
19
20 this.languages = sortBy(l, 'label')
21 }
22
23 show () {
24 this.modalService.open(this.modal)
25 }
26
27 buildLanguageLink (lang: { id: string }) {
28 return window.location.origin + '/' + lang.id
29 }
30
31 }