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