forked from MapComplete/MapComplete
Docs: Improve docs, fix doc script
This commit is contained in:
parent
d036350893
commit
124cfad8f8
142 changed files with 9404 additions and 908 deletions
|
@ -1,71 +0,0 @@
|
|||
import { Utils } from "../Utils"
|
||||
import TagRenderingConfig from "../Models/ThemeConfig/TagRenderingConfig"
|
||||
import { TagRenderingConfigJson } from "../Models/ThemeConfig/Json/TagRenderingConfigJson"
|
||||
import BaseUIElement from "../UI/BaseUIElement"
|
||||
import Combine from "../UI/Base/Combine"
|
||||
import Title from "../UI/Base/Title"
|
||||
import { FixedUiElement } from "../UI/Base/FixedUiElement"
|
||||
import List from "../UI/Base/List"
|
||||
|
||||
export default class SharedTagRenderings {
|
||||
public static SharedTagRendering: Map<string, TagRenderingConfig> =
|
||||
SharedTagRenderings.generatedSharedFields()
|
||||
public static SharedTagRenderingJson: Map<string, TagRenderingConfigJson> =
|
||||
SharedTagRenderings.generatedSharedFieldsJsons()
|
||||
|
||||
private static generatedSharedFields(): Map<string, TagRenderingConfig> {
|
||||
const configJsons = SharedTagRenderings.generatedSharedFieldsJsons()
|
||||
const d = new Map<string, TagRenderingConfig>()
|
||||
for (const key of Array.from(configJsons.keys())) {
|
||||
try {
|
||||
d.set(
|
||||
key,
|
||||
new TagRenderingConfig(configJsons.get(key), `SharedTagRenderings.${key}`)
|
||||
)
|
||||
} catch (e) {
|
||||
if (!Utils.runningFromConsole) {
|
||||
console.error(
|
||||
"BUG: could not parse",
|
||||
key,
|
||||
" from questions.json - this error happened during the build step of the SharedTagRenderings",
|
||||
e
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
return d
|
||||
}
|
||||
|
||||
private static generatedSharedFieldsJsons(): Map<string, TagRenderingConfigJson> {
|
||||
const dict = new Map<string, TagRenderingConfigJson>()
|
||||
|
||||
// TODO FIXME
|
||||
|
||||
return dict
|
||||
}
|
||||
|
||||
public static HelpText(): BaseUIElement {
|
||||
return new Combine([
|
||||
new Combine([
|
||||
new Title("Builtin questions", 1),
|
||||
|
||||
"The following items can be easily reused in your layers",
|
||||
]).SetClass("flex flex-col"),
|
||||
|
||||
...Array.from(SharedTagRenderings.SharedTagRendering.keys()).map((key) => {
|
||||
const tr = SharedTagRenderings.SharedTagRendering.get(key)
|
||||
let mappings: BaseUIElement = undefined
|
||||
if (tr.mappings?.length > 0) {
|
||||
mappings = new List(tr.mappings.map((m) => m.then.textFor("en")))
|
||||
}
|
||||
return new Combine([
|
||||
new Title(key),
|
||||
tr.render?.textFor("en"),
|
||||
tr.question?.textFor("en") ??
|
||||
new FixedUiElement("Read-only tagrendering").SetClass("font-bold"),
|
||||
mappings,
|
||||
]).SetClass("flex flex-col")
|
||||
}),
|
||||
]).SetClass("flex flex-col")
|
||||
}
|
||||
}
|
|
@ -1,5 +1,4 @@
|
|||
import TagRenderingConfig from "./TagRenderingConfig"
|
||||
import SharedTagRenderings from "../../Customizations/SharedTagRenderings"
|
||||
import { TagRenderingConfigJson } from "./Json/TagRenderingConfigJson"
|
||||
|
||||
export default class WithContextLoader {
|
||||
|
@ -26,12 +25,6 @@ export default class WithContextLoader {
|
|||
`${translationContext ?? this._context}.${key}.default value`
|
||||
)
|
||||
}
|
||||
if (typeof v === "string") {
|
||||
const shared = SharedTagRenderings.SharedTagRendering.get(v)
|
||||
if (shared) {
|
||||
return shared
|
||||
}
|
||||
}
|
||||
if (Object.keys(v).length === 1 && typeof v["render"] === "string") {
|
||||
throw `At ${
|
||||
translationContext ?? "<unknown>"
|
||||
|
|
|
@ -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)
|
||||
|
@ -23,26 +23,33 @@ export default class Locale {
|
|||
* @private
|
||||
*/
|
||||
private static setup() {
|
||||
|
||||
let source: UIEventSource<string>
|
||||
|
||||
if (QueryParameters.wasInitialized("language") || Utils.runningFromConsole) {
|
||||
if(!Utils.runningFromConsole){
|
||||
console.debug("Language was initialized via URL-parameter - using the URL parameter as store instead of local storage", QueryParameters.wasInitialized("language"))
|
||||
if (!Utils.runningFromConsole) {
|
||||
console.debug(
|
||||
"Language was initialized via URL-parameter - using the URL parameter as store instead of local storage",
|
||||
QueryParameters.wasInitialized("language")
|
||||
)
|
||||
}
|
||||
source = QueryParameters.GetQueryParameter(
|
||||
"language",
|
||||
undefined,
|
||||
["The language to display MapComplete in.",
|
||||
[
|
||||
"The language to display MapComplete in.",
|
||||
"The user display language is determined in the following order:",
|
||||
"- If the user did log in and did set their language before with MapComplete, use this language",
|
||||
"- If the user visited MapComplete before and did change their language, use the language as set by this URL-parameter. This will _disable_ saving the language to localStorage in case a non-logged-in user changes their language",
|
||||
"- Use the navigator-language (if available)",
|
||||
"- Use English",
|
||||
"",
|
||||
"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",
|
||||
"",
|
||||
"Note that this URL-parameter is not added to the URL-bar by default.",
|
||||
"Note that the _loading_ screen will always use the navigator language.",
|
||||
"",
|
||||
"Translations are never complete. If a translation in a certain language is missing, English is used as fallback."].join("\n"),
|
||||
"Translations are never complete. If a translation in a certain language is missing, English is used as fallback.",
|
||||
].join("\n")
|
||||
)
|
||||
} else {
|
||||
let browserLanguage = "en"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue