mirror of
https://github.com/bitwarden/browser
synced 2025-12-20 02:03:39 +00:00
[PS-713] Fix locale search bug (#3014)
* [PS-713] Fix locale search bug * [PS-713] Add new locales to start at 1 char search * [PS-713] Switch to ReplaySubject and other edits from PR comments * PS-713: Add destroy to other sub and make locale inline a const * PS-713: Use firstValueFrom instead of takeUntil * PS-713: get this.locale asynchronously Co-authored-by: Colton Hurst <churst@bitwarden.com>
This commit is contained in:
@@ -1,7 +1,10 @@
|
||||
import { Observable, ReplaySubject } from "rxjs";
|
||||
|
||||
import { I18nService as I18nServiceAbstraction } from "../abstractions/i18n.service";
|
||||
|
||||
export class I18nService implements I18nServiceAbstraction {
|
||||
locale: string;
|
||||
private _locale = new ReplaySubject<string>(1);
|
||||
locale$: Observable<string> = this._locale.asObservable();
|
||||
// First locale is the default (English)
|
||||
supportedTranslationLocales: string[] = ["en"];
|
||||
translationLocale: string;
|
||||
@@ -85,10 +88,14 @@ export class I18nService implements I18nServiceAbstraction {
|
||||
}
|
||||
|
||||
this.inited = true;
|
||||
this.locale = this.translationLocale = locale != null ? locale : this.systemLanguage;
|
||||
this.translationLocale = locale != null ? locale : this.systemLanguage;
|
||||
this._locale.next(this.translationLocale);
|
||||
|
||||
try {
|
||||
this.collator = new Intl.Collator(this.locale, { numeric: true, sensitivity: "base" });
|
||||
this.collator = new Intl.Collator(this.translationLocale, {
|
||||
numeric: true,
|
||||
sensitivity: "base",
|
||||
});
|
||||
} catch {
|
||||
this.collator = null;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user