diff options
Diffstat (limited to '')
-rw-r--r-- | src/pybind/mgr/dashboard/frontend/src/app/shared/services/language.service.ts | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/src/pybind/mgr/dashboard/frontend/src/app/shared/services/language.service.ts b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/language.service.ts new file mode 100644 index 000000000..d2705ee36 --- /dev/null +++ b/src/pybind/mgr/dashboard/frontend/src/app/shared/services/language.service.ts @@ -0,0 +1,23 @@ +import { HttpClient } from '@angular/common/http'; +import { Inject, Injectable, LOCALE_ID } 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'); + } +} |