1 import { Component, OnInit } from '@angular/core';
3 import _ from 'lodash';
5 import { LanguageService } from '~/app/shared/services/language.service';
6 import { SupportedLanguages } from './supported-languages.enum';
9 selector: 'cd-language-selector',
10 templateUrl: './language-selector.component.html',
11 styleUrls: ['./language-selector.component.scss']
13 export class LanguageSelectorComponent implements OnInit {
14 allLanguages = SupportedLanguages;
15 supportedLanguages: Record<string, any> = {};
16 selectedLanguage: string;
18 constructor(private languageService: LanguageService) {}
21 this.selectedLanguage = this.languageService.getLocale();
23 this.languageService.getLanguages().subscribe((langs) => {
24 this.supportedLanguages = _.pick(SupportedLanguages, langs) as Object;
29 * Jest is being more restricted regarding spying on the reload method.
30 * This will allow us to spyOn this method instead.
33 window.location.reload();
36 changeLanguage(lang: string) {
37 this.languageService.setLocale(lang);