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 supportedLanguages: Record<string, any> = {};
18 selectedLanguage: string;
20 constructor(private languageService: LanguageService) {}
23 this.selectedLanguage = this.languageService.getLocale();
25 this.languageService.getLanguages().subscribe((langs) => {
26 this.supportedLanguages = _.pick(SupportedLanguages, langs) as Object;
31 * Jest is being more restricted regarding spying on the reload method.
32 * This will allow us to spyOn this method instead.
35 window.location.reload();
38 changeLanguage(lang: string) {
39 this.languageService.setLocale(lang);