All files / src/app/shared/services language.service.ts

100% Statements 16/16
66.67% Branches 4/6
100% Functions 5/5
100% Lines 13/13

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 2598x 98x 98x   98x         98x 16x   98x 26x     98x 12x     98x 27x   98x  
import { HttpClient } from '@angular/common/http';
import { Inject, LOCALE_ID } from '@angular/core';
import { Injectable } from '@angular/core';
 
import { environment } from '../../../environments/environment';
 
@Injectable({
  providedIn: 'root'
})
export class LanguageService {
  constructor(private http: HttpClient, @Inject(LOCALE_ID) protected localeId: string) {}
 
  getLocale(): string {
    return this.localeId || environment.default_lang;
  }
 
  setLocale(lang: string) {
    document.cookie = `cd-lang=${lang}`;
  }
 
  getLanguages() {
    return this.http.get<string[]>('ui-api/langs');
  }
}