Fix: URL-parameter language disables the language picker, fix #1506

This commit is contained in:
Pieter Vander Vennet 2023-07-27 01:50:23 +02:00
parent 58f526734d
commit 2f5c89f8c5
5 changed files with 36 additions and 6 deletions

View file

@ -8,11 +8,16 @@ import Lazy from "./Base/Lazy"
import Toggle from "./Input/Toggle"
import LanguageUtils from "../Utils/LanguageUtils"
import { UIEventSource } from "../Logic/UIEventSource"
import { QueryParameters } from "../Logic/Web/QueryParameters"
export default class LanguagePicker extends Toggle {
constructor(languages: string[], assignTo: UIEventSource<string>) {
console.log("Constructing a language pîcker for languages", languages)
if (languages === undefined || languages.length <= 1) {
if (
languages === undefined ||
languages.length <= 1 ||
QueryParameters.wasInitialized("language")
) {
super(undefined, undefined, undefined)
} else {
const normalPicker = LanguagePicker.dropdownFor(languages, assignTo ?? Locale.language)

View file

@ -39,8 +39,8 @@ export default class Locale {
"The language to display MapComplete in.",
"The user display language is determined in the following order:",
"",
"1. Use the language as set by the URL-parameter `language`. This will _disable_ setting the language by the user",
"1. If the user did log in and did set their language before with MapComplete, use this language. This language selection is synchronized accross devices using the openstreetmap.org user preferences.",
"2. Use the language as set by the URL-parameter `language`. This will _disable_ saving the language to localStorage in case a non-logged-in user changes their language",
"3. If the user visited MapComplete before and did change their language manually, this changed language will be saved in local storage. Use the language from local storage",
"4. Use the navigator-language (if available)",
"5. Use English",