1 import { Component, Input, OnInit } from '@angular/core';
3 import * as _ from 'lodash';
5 import { LanguageService } from '../../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 {
17 allLanguages = SupportedLanguages;
18 supportedLanguages: Record<string, any> = {};
19 selectedLanguage: string;
21 constructor(private languageService: LanguageService) {}
24 this.selectedLanguage = this.languageService.getLocale();
26 this.languageService.getLanguages().subscribe((langs) => {
27 this.supportedLanguages = _.pick(SupportedLanguages, langs) as Object;
32 * Jest is being more restricted regarding spying on the reload method.
33 * This will allow us to spyOn this method instead.
36 window.location.reload();
39 changeLanguage(lang: string) {
40 this.languageService.setLocale(lang);