forked from MapComplete/MapComplete
Fix: only check browserLanguage if navigator is defined; fixes tests
This commit is contained in:
parent
215286a5af
commit
a1fa3b4942
1 changed files with 10 additions and 7 deletions
|
@ -1,7 +1,7 @@
|
|||
import { UIEventSource } from "../../Logic/UIEventSource"
|
||||
import { LocalStorageSource } from "../../Logic/Web/LocalStorageSource"
|
||||
import { Utils } from "../../Utils"
|
||||
import { QueryParameters } from "../../Logic/Web/QueryParameters"
|
||||
import {UIEventSource} from "../../Logic/UIEventSource"
|
||||
import {LocalStorageSource} from "../../Logic/Web/LocalStorageSource"
|
||||
import {Utils} from "../../Utils"
|
||||
import {QueryParameters} from "../../Logic/Web/QueryParameters"
|
||||
|
||||
export default class Locale {
|
||||
public static showLinkToWeblate: UIEventSource<boolean> = new UIEventSource<boolean>(false)
|
||||
|
@ -12,7 +12,10 @@ export default class Locale {
|
|||
public static language: UIEventSource<string> = Locale.setup()
|
||||
|
||||
private static setup() {
|
||||
const browserLanguage =navigator.languages?.[0] ?? navigator.language ?? "en"
|
||||
let browserLanguage = "en"
|
||||
if (typeof navigator !== "undefined") {
|
||||
browserLanguage = navigator.languages?.[0] ?? navigator.language ?? "en"
|
||||
}
|
||||
const source = LocalStorageSource.Get("language", browserLanguage)
|
||||
if (!Utils.runningFromConsole) {
|
||||
// @ts-ignore
|
||||
|
@ -20,7 +23,7 @@ export default class Locale {
|
|||
source.setData(language)
|
||||
}
|
||||
}
|
||||
if(QueryParameters.wasInitialized("language")){
|
||||
if (QueryParameters.wasInitialized("language")) {
|
||||
const qp = QueryParameters.GetQueryParameter(
|
||||
"language",
|
||||
undefined,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue