]> git.proxmox.com Git - ceph.git/blob - ceph/src/pybind/mgr/dashboard/frontend/src/app/shared/components/language-selector/language-selector.component.ts
update source to Ceph Pacific 16.2.2
[ceph.git] / ceph / src / pybind / mgr / dashboard / frontend / src / app / shared / components / language-selector / language-selector.component.ts
1 import { Component, OnInit } from '@angular/core';
2
3 import _ from 'lodash';
4
5 import { LanguageService } from '~/app/shared/services/language.service';
6 import { SupportedLanguages } from './supported-languages.enum';
7
8 @Component({
9 selector: 'cd-language-selector',
10 templateUrl: './language-selector.component.html',
11 styleUrls: ['./language-selector.component.scss']
12 })
13 export class LanguageSelectorComponent implements OnInit {
14 allLanguages = SupportedLanguages;
15 supportedLanguages: Record<string, any> = {};
16 selectedLanguage: string;
17
18 constructor(private languageService: LanguageService) {}
19
20 ngOnInit() {
21 this.selectedLanguage = this.languageService.getLocale();
22
23 this.languageService.getLanguages().subscribe((langs) => {
24 this.supportedLanguages = _.pick(SupportedLanguages, langs) as Object;
25 });
26 }
27
28 /**
29 * Jest is being more restricted regarding spying on the reload method.
30 * This will allow us to spyOn this method instead.
31 */
32 reloadWindow() {
33 window.location.reload();
34 }
35
36 changeLanguage(lang: string) {
37 this.languageService.setLocale(lang);
38 this.reloadWindow();
39 }
40 }