Switch translation mode on Shift+T
This commit is contained in:
parent
ef16058249
commit
9b505f33d0
2 changed files with 62 additions and 53 deletions
|
@ -41,6 +41,8 @@ export default class UserRelatedState {
|
||||||
public readonly showAllQuestionsAtOnce: UIEventSource<boolean>
|
public readonly showAllQuestionsAtOnce: UIEventSource<boolean>
|
||||||
public readonly showTags: UIEventSource<"no" | undefined | "always" | "yes" | "full">
|
public readonly showTags: UIEventSource<"no" | undefined | "always" | "yes" | "full">
|
||||||
public readonly showCrosshair: UIEventSource<"yes" | "always" | "no" | undefined>
|
public readonly showCrosshair: UIEventSource<"yes" | "always" | "no" | undefined>
|
||||||
|
public readonly translationMode: UIEventSource<"false" | "true" | "mobile" | undefined | string>
|
||||||
|
|
||||||
public readonly fixateNorth: UIEventSource<undefined | "yes">
|
public readonly fixateNorth: UIEventSource<undefined | "yes">
|
||||||
public readonly a11y: UIEventSource<undefined | "always" | "never" | "default">
|
public readonly a11y: UIEventSource<undefined | "always" | "never" | "default">
|
||||||
public readonly homeLocation: FeatureSource
|
public readonly homeLocation: FeatureSource
|
||||||
|
@ -86,30 +88,11 @@ export default class UserRelatedState {
|
||||||
) {
|
) {
|
||||||
this.osmConnection = osmConnection
|
this.osmConnection = osmConnection
|
||||||
this._mapProperties = mapProperties
|
this._mapProperties = mapProperties
|
||||||
{
|
|
||||||
const translationMode: UIEventSource<undefined | "true" | "false" | "mobile" | string> =
|
|
||||||
this.osmConnection.GetPreference("translation-mode", "false")
|
|
||||||
translationMode.addCallbackAndRunD((mode) => {
|
|
||||||
mode = mode.toLowerCase()
|
|
||||||
if (mode === "true" || mode === "yes") {
|
|
||||||
Locale.showLinkOnMobile.setData(false)
|
|
||||||
Locale.showLinkToWeblate.setData(true)
|
|
||||||
} else if (mode === "false" || mode === "no") {
|
|
||||||
Locale.showLinkToWeblate.setData(false)
|
|
||||||
} else if (mode === "mobile") {
|
|
||||||
Locale.showLinkOnMobile.setData(true)
|
|
||||||
Locale.showLinkToWeblate.setData(true)
|
|
||||||
} else {
|
|
||||||
Locale.showLinkOnMobile.setData(false)
|
|
||||||
Locale.showLinkToWeblate.setData(false)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|
||||||
this.showAllQuestionsAtOnce = UIEventSource.asBoolean(
|
this.showAllQuestionsAtOnce = UIEventSource.asBoolean(
|
||||||
this.osmConnection.GetPreference("show-all-questions", "false", {
|
this.osmConnection.GetPreference("show-all-questions", "false", {
|
||||||
documentation:
|
documentation:
|
||||||
"Either 'true' or 'false'. If set, all questions will be shown all at once",
|
"Either 'true' or 'false'. If set, all questions will be shown all at once"
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
this.language = this.osmConnection.GetPreference("language")
|
this.language = this.osmConnection.GetPreference("language")
|
||||||
|
@ -129,7 +112,7 @@ export default class UserRelatedState {
|
||||||
undefined,
|
undefined,
|
||||||
{
|
{
|
||||||
documentation:
|
documentation:
|
||||||
"The ID of a layer or layer category that MapComplete uses by default",
|
"The ID of a layer or layer category that MapComplete uses by default"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -137,15 +120,15 @@ export default class UserRelatedState {
|
||||||
"preferences-add-new-mode",
|
"preferences-add-new-mode",
|
||||||
"button_click_right",
|
"button_click_right",
|
||||||
{
|
{
|
||||||
documentation: "How adding a new feature is done",
|
documentation: "How adding a new feature is done"
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
this.imageLicense = this.osmConnection.GetPreference("pictures-license", "CC0", {
|
this.imageLicense = this.osmConnection.GetPreference("pictures-license", "CC0", {
|
||||||
documentation: "The license under which new images are uploaded",
|
documentation: "The license under which new images are uploaded"
|
||||||
})
|
})
|
||||||
this.installedUserThemes = this.InitInstalledUserThemes()
|
this.installedUserThemes = this.InitInstalledUserThemes()
|
||||||
|
this.translationMode = this.initTranslationMode()
|
||||||
this.homeLocation = this.initHomeLocation()
|
this.homeLocation = this.initHomeLocation()
|
||||||
|
|
||||||
this.preferencesAsTags = this.initAmendedPrefs(layout, featureSwitches)
|
this.preferencesAsTags = this.initAmendedPrefs(layout, featureSwitches)
|
||||||
|
@ -161,6 +144,29 @@ export default class UserRelatedState {
|
||||||
this.language.syncWith(Locale.language)
|
this.language.syncWith(Locale.language)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private initTranslationMode(): UIEventSource<"false" | "true" | "mobile" | undefined | string> {
|
||||||
|
const translationMode: UIEventSource<undefined | "true" | "false" | "mobile" | string> =
|
||||||
|
this.osmConnection.GetPreference("translation-mode", "false")
|
||||||
|
translationMode.addCallbackAndRunD((mode) => {
|
||||||
|
mode = mode.toLowerCase()
|
||||||
|
if (mode === "true" || mode === "yes") {
|
||||||
|
Locale.showLinkOnMobile.setData(false)
|
||||||
|
Locale.showLinkToWeblate.setData(true)
|
||||||
|
} else if (mode === "false" || mode === "no") {
|
||||||
|
Locale.showLinkToWeblate.setData(false)
|
||||||
|
} else if (mode === "mobile") {
|
||||||
|
Locale.showLinkOnMobile.setData(true)
|
||||||
|
Locale.showLinkToWeblate.setData(true)
|
||||||
|
} else {
|
||||||
|
Locale.showLinkOnMobile.setData(false)
|
||||||
|
Locale.showLinkToWeblate.setData(false)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
return translationMode
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private static initUserSettingsState(): LayerConfig {
|
private static initUserSettingsState(): LayerConfig {
|
||||||
try {
|
try {
|
||||||
return new LayerConfig(<LayerConfigJson>usersettings, "userinformationpanel")
|
return new LayerConfig(<LayerConfigJson>usersettings, "userinformationpanel")
|
||||||
|
@ -233,7 +239,7 @@ export default class UserRelatedState {
|
||||||
icon: layout.icon,
|
icon: layout.icon,
|
||||||
title: layout.title.translations,
|
title: layout.title.translations,
|
||||||
shortDescription: layout.shortDescription.translations,
|
shortDescription: layout.shortDescription.translations,
|
||||||
definition: layout["definition"],
|
definition: layout["definition"]
|
||||||
})
|
})
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -273,13 +279,13 @@ export default class UserRelatedState {
|
||||||
id: "home",
|
id: "home",
|
||||||
"user:home": "yes",
|
"user:home": "yes",
|
||||||
_lon: homeLonLat[0],
|
_lon: homeLonLat[0],
|
||||||
_lat: homeLonLat[1],
|
_lat: homeLonLat[1]
|
||||||
},
|
},
|
||||||
geometry: {
|
geometry: {
|
||||||
type: "Point",
|
type: "Point",
|
||||||
coordinates: homeLonLat,
|
coordinates: homeLonLat
|
||||||
},
|
}
|
||||||
},
|
}
|
||||||
]
|
]
|
||||||
})
|
})
|
||||||
return new StaticFeatureSource(feature)
|
return new StaticFeatureSource(feature)
|
||||||
|
@ -300,7 +306,7 @@ export default class UserRelatedState {
|
||||||
_applicationOpened: new Date().toISOString(),
|
_applicationOpened: new Date().toISOString(),
|
||||||
_supports_sharing:
|
_supports_sharing:
|
||||||
typeof window === "undefined" ? "no" : window.navigator.share ? "yes" : "no",
|
typeof window === "undefined" ? "no" : window.navigator.share ? "yes" : "no",
|
||||||
_iframe: Utils.isIframe ? "yes" : "no",
|
_iframe: Utils.isIframe ? "yes" : "no"
|
||||||
})
|
})
|
||||||
|
|
||||||
for (const key in Constants.userJourney) {
|
for (const key in Constants.userJourney) {
|
||||||
|
@ -333,12 +339,10 @@ export default class UserRelatedState {
|
||||||
|
|
||||||
amendedPrefs.ping()
|
amendedPrefs.ping()
|
||||||
})
|
})
|
||||||
const translationMode = osmConnection.GetPreference("translation-mode")
|
|
||||||
|
|
||||||
Locale.language.mapD(
|
Locale.language.mapD(
|
||||||
(language) => {
|
(language) => {
|
||||||
amendedPrefs.data["_language"] = language
|
amendedPrefs.data["_language"] = language
|
||||||
const trmode = translationMode.data
|
const trmode = this.translationMode.data
|
||||||
if ((trmode === "true" || trmode === "mobile") && layout !== undefined) {
|
if ((trmode === "true" || trmode === "mobile") && layout !== undefined) {
|
||||||
const extraInspection = UserRelatedState.usersettingsConfig
|
const extraInspection = UserRelatedState.usersettingsConfig
|
||||||
const missing = layout.missingTranslations(extraInspection)
|
const missing = layout.missingTranslations(extraInspection)
|
||||||
|
@ -360,13 +364,13 @@ export default class UserRelatedState {
|
||||||
language,
|
language,
|
||||||
"themes",
|
"themes",
|
||||||
layout.id
|
layout.id
|
||||||
),
|
)
|
||||||
}
|
}
|
||||||
: undefined,
|
: undefined,
|
||||||
...missingLayers.map((id) => ({
|
...missingLayers.map((id) => ({
|
||||||
id: "layer:" + id,
|
id: "layer:" + id,
|
||||||
link: LinkToWeblate.hrefToWeblateZen(language, "layers", id),
|
link: LinkToWeblate.hrefToWeblateZen(language, "layers", id)
|
||||||
})),
|
}))
|
||||||
])
|
])
|
||||||
const untranslated_count = untranslated.length
|
const untranslated_count = untranslated.length
|
||||||
amendedPrefs.data["_translation_total"] = "" + total
|
amendedPrefs.data["_translation_total"] = "" + total
|
||||||
|
@ -378,7 +382,7 @@ export default class UserRelatedState {
|
||||||
}
|
}
|
||||||
amendedPrefs.ping()
|
amendedPrefs.ping()
|
||||||
},
|
},
|
||||||
[translationMode]
|
[this.translationMode]
|
||||||
)
|
)
|
||||||
|
|
||||||
this.mangroveIdentity.getKeyId().addCallbackAndRun((kid) => {
|
this.mangroveIdentity.getKeyId().addCallbackAndRun((kid) => {
|
||||||
|
|
|
@ -704,7 +704,12 @@ export default class ThemeViewState implements SpecialVisualizationState {
|
||||||
},
|
},
|
||||||
Translations.t.hotkeyDocumentation.translationMode,
|
Translations.t.hotkeyDocumentation.translationMode,
|
||||||
() => {
|
() => {
|
||||||
Locale.showLinkToWeblate.setData(!Locale.showLinkToWeblate.data)
|
const tm = this.userRelatedState.translationMode
|
||||||
|
if(tm.data === "false"){
|
||||||
|
tm.setData("true")
|
||||||
|
} else {
|
||||||
|
tm.setData("false")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue