Skip to content

Commit

Permalink
work on #93 to allow for &setlocale
Browse files Browse the repository at this point in the history
  • Loading branch information
seiyria committed Jun 23, 2024
1 parent fbf8a5b commit 2af222c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/app/locale.service.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
import { inject, Injectable, signal } from '@angular/core';
import { LocalStorageService } from 'ngx-webstorage';
import { environment } from '../environments/environment';
import { WINDOW } from './_shared/helpers';

@Injectable({
providedIn: 'root',
})
export class LocaleService {
private window = inject(WINDOW);
private localStorageService = inject(LocalStorageService);

private locale = signal<string>('en-US');
Expand All @@ -24,6 +26,12 @@ export class LocaleService {

public async init() {
this.locale.set(this.localStorageService.retrieve('locale') ?? 'en-US');

const urlParams = new URLSearchParams(this.window.location.search);
const setLocaleFromURL = urlParams.get('setlocale');
if (setLocaleFromURL) {
this.locale.set(setLocaleFromURL);
}
}

public setLocales(locales: string[]) {
Expand Down

0 comments on commit 2af222c

Please sign in to comment.