forked from MapComplete/MapComplete
Fix delete button, remove Translations.WT
This commit is contained in:
parent
50a7597c5a
commit
1271f24160
11 changed files with 69 additions and 62 deletions
|
@ -16,7 +16,7 @@ export default class TitleHandler {
|
|||
const currentTitle: UIEventSource<string> = state.selectedElement.map(
|
||||
selected => {
|
||||
const layout = state.layoutToUse
|
||||
const defaultTitle = Translations.WT(layout?.title)?.txt ?? "MapComplete"
|
||||
const defaultTitle = layout?.title?.txt ?? "MapComplete"
|
||||
|
||||
if (selected === undefined) {
|
||||
return defaultTitle
|
||||
|
|
|
@ -148,6 +148,26 @@ export default class Wikidata {
|
|||
return src;
|
||||
}
|
||||
|
||||
public static async searchAdvanced(text: string, options: WikidataSearchoptions & {
|
||||
instanceOf: number}){
|
||||
const sparql = `SELECT * WHERE {
|
||||
SERVICE wikibase:mwapi {
|
||||
bd:serviceParam wikibase:api "EntitySearch" .
|
||||
bd:serviceParam wikibase:endpoint "www.wikidata.org" .
|
||||
bd:serviceParam mwapi:search "${text}" .
|
||||
bd:serviceParam mwapi:language "${options.lang}" .
|
||||
?item wikibase:apiOutputItem mwapi:item .
|
||||
?num wikibase:apiOrdinal true .
|
||||
}
|
||||
?item (wdt:P279|wdt:P31) wd:Q${options.instanceOf}
|
||||
} ORDER BY ASC(?num) LIMIT ${options.maxCount}`
|
||||
const url = wds.sparqlQuery(sparql)
|
||||
|
||||
const result = await Utils.downloadJson(url, {"User-Agent": "MapComplete script"})
|
||||
return result.results.bindings
|
||||
|
||||
}
|
||||
|
||||
public static async search(
|
||||
search: string,
|
||||
options?: WikidataSearchoptions,
|
||||
|
|
|
@ -191,7 +191,7 @@ export default class SimpleAddUI extends Toggle {
|
|||
preset.icon(),
|
||||
new Combine([
|
||||
title.SetClass("font-bold"),
|
||||
Translations.WT(preset.description)?.FirstSentence()
|
||||
preset.description?.FirstSentence()
|
||||
]).SetClass("flex flex-col")
|
||||
)
|
||||
}
|
||||
|
|
|
@ -202,7 +202,7 @@ export default class DeleteWizard extends Toggle {
|
|||
private static generateDeleteTagRenderingConfig(softDeletionTags: TagsFilter,
|
||||
nonDeleteOptions: { if: TagsFilter; then: Translation }[],
|
||||
extraDeleteReasons: { explanation: Translation; changesetMessage: string }[],
|
||||
currentTags: any) {
|
||||
currentTags: any): TagRenderingConfig {
|
||||
const t = Translations.t.delete
|
||||
nonDeleteOptions = nonDeleteOptions ?? []
|
||||
let softDeletionTagsStr = []
|
||||
|
|
|
@ -613,7 +613,7 @@ export class ImportPointButton extends AbstractImportButton {
|
|||
icon: () => new Img(args.icon),
|
||||
layerToAddTo: state.filteredLayers.data.filter(l => l.layerDef.id === args.targetLayer)[0],
|
||||
name: args.text,
|
||||
title: Translations.WT(args.text),
|
||||
title: Translations.T(args.text),
|
||||
preciseInput: preciseInputSpec, // must be explicitely assigned, if 'undefined' won't work otherwise
|
||||
boundsFactor: 3
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ export default class MoveWizard extends Toggle {
|
|||
moveReason.setData(reason)
|
||||
moveButton = new SubtleButton(
|
||||
reason.icon.SetStyle("height: 1.5rem; width: 1.5rem;"),
|
||||
Translations.WT(reason.invitingText)
|
||||
Translations.T(reason.invitingText)
|
||||
).onClick(() => {
|
||||
currentStep.setData("pick_location")
|
||||
})
|
||||
|
|
|
@ -207,7 +207,7 @@ export default class TagRenderingQuestion extends Combine {
|
|||
applicableMappings.map((mapping, i) => {
|
||||
return {
|
||||
value: new And([mapping.if, ...allIfNotsExcept(i)]),
|
||||
shown: Translations.WT(mapping.then)
|
||||
shown: Translations.T(mapping.then)
|
||||
}
|
||||
})
|
||||
)
|
||||
|
|
|
@ -22,6 +22,25 @@ export default class Translations {
|
|||
return s;
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a string or an object into a typed translation.
|
||||
* Translation objects ('Translation' and 'TypedTranslation') are converted/returned
|
||||
*
|
||||
* Translations.T("some text") // => new TypedTranslation({"*": "some text"})
|
||||
* Translations.T("some text").txt // => "some text"
|
||||
*
|
||||
* const t = new Translation({"nl": "vertaling", "en": "translation"})
|
||||
* Translations.T(t) // => new TypedTranslation<object>({"nl": "vertaling", "en": "translation"})
|
||||
*
|
||||
* const t = new TypedTranslation({"nl": "vertaling", "en": "translation"})
|
||||
* Translations.T(t) // => t
|
||||
*
|
||||
* const json: any = {"en": "English", "nl": "Nederlands"};
|
||||
* const translation = Translations.T(new Translation(json));
|
||||
* translation.textFor("en") // => "English"
|
||||
* translation.textFor("nl") // => "Nederlands"
|
||||
*
|
||||
*/
|
||||
static T(t: string | any, context = undefined): TypedTranslation<object> {
|
||||
if (t === undefined || t === null) {
|
||||
return undefined;
|
||||
|
@ -30,7 +49,7 @@ export default class Translations {
|
|||
t = "" + t
|
||||
}
|
||||
if (typeof t === "string") {
|
||||
return new TypedTranslation({"*": t}, context);
|
||||
return new TypedTranslation<object>({"*": t}, context);
|
||||
}
|
||||
if (t.render !== undefined) {
|
||||
const msg = "Creating a translation, but this object contains a 'render'-field. Use the translation directly"
|
||||
|
@ -40,30 +59,12 @@ export default class Translations {
|
|||
if (t instanceof TypedTranslation) {
|
||||
return t;
|
||||
}
|
||||
return new TypedTranslation(t, context);
|
||||
if(t instanceof Translation){
|
||||
return new TypedTranslation<object>(t.translations)
|
||||
}
|
||||
return new TypedTranslation<object>(t, context);
|
||||
}
|
||||
|
||||
/**
|
||||
* 'Wrap Translation': given an object containing translations OR a string, returns a translation object
|
||||
*
|
||||
* const json: any = {"en": "English", "nl": "Nederlands"};
|
||||
* const translation = Translations.WT(new Translation(json));
|
||||
* translation.textFor("en") // => "English"
|
||||
* translation.textFor("nl") // => "Nederlands"
|
||||
*/
|
||||
public static WT(s: string | Translation): Translation {
|
||||
if (s === undefined || s === null) {
|
||||
return undefined;
|
||||
}
|
||||
if (typeof (s) === "string") {
|
||||
return new Translation({'*': s});
|
||||
}
|
||||
if (s instanceof Translation) {
|
||||
return s.Clone() /* MUST CLONE HERE! */;
|
||||
}
|
||||
console.error("Trying to Translation.WT, but got ", s)
|
||||
throw "??? Not a valid translation"
|
||||
}
|
||||
|
||||
public static CountTranslations() {
|
||||
const queue: any = [Translations.t];
|
||||
|
|
|
@ -1,16 +1,13 @@
|
|||
{
|
||||
"id": "mapcomplete-changes",
|
||||
"title": {
|
||||
"en": "Changes made with MapComplete",
|
||||
"de": "Änderungen mit MapComplete"
|
||||
"en": "Changes made with MapComplete"
|
||||
},
|
||||
"shortDescription": {
|
||||
"en": "Shows changes made by MapComplete",
|
||||
"de": "Zeigt Änderungen von MapComplete"
|
||||
"en": "Shows changes made by MapComplete"
|
||||
},
|
||||
"description": {
|
||||
"en": "This maps shows all the changes made with MapComplete",
|
||||
"de": "Diese Karte zeigt alle Änderungen die mit MapComplete gemacht wurden"
|
||||
"en": "This maps shows all the changes made with MapComplete"
|
||||
},
|
||||
"maintainer": "",
|
||||
"icon": "./assets/svg/logo.svg",
|
||||
|
@ -25,8 +22,7 @@
|
|||
{
|
||||
"id": "mapcomplete-changes",
|
||||
"name": {
|
||||
"en": "Changeset centers",
|
||||
"de": "Schwerpunkte von Änderungssätzen"
|
||||
"en": "Changeset centers"
|
||||
},
|
||||
"minzoom": 0,
|
||||
"source": {
|
||||
|
@ -40,41 +36,35 @@
|
|||
],
|
||||
"title": {
|
||||
"render": {
|
||||
"en": "Changeset for {theme}",
|
||||
"de": "Änderungen für {theme}"
|
||||
"en": "Changeset for {theme}"
|
||||
}
|
||||
},
|
||||
"description": {
|
||||
"en": "Shows all MapComplete changes",
|
||||
"de": "Zeigt alle MapComplete Änderungen"
|
||||
"en": "Shows all MapComplete changes"
|
||||
},
|
||||
"tagRenderings": [
|
||||
{
|
||||
"id": "render_id",
|
||||
"render": {
|
||||
"en": "Changeset <a href='https://openstreetmap.org/changeset/{id}' target='_blank'>{id}</a>",
|
||||
"de": "Änderung <a href='https://openstreetmap.org/changeset/{id}' target='_blank'>{id}</a>"
|
||||
"en": "Changeset <a href='https://openstreetmap.org/changeset/{id}' target='_blank'>{id}</a>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "contributor",
|
||||
"render": {
|
||||
"en": "Change made by <a href='https://openstreetmap.org/user/{_last_edit:contributor}' target='_blank'>{_last_edit:contributor}</a>",
|
||||
"de": "Änderung wurde von <a href='https://openstreetmap.org/user/{_last_edit:contributor}' target='_blank'>{_last_edit:contributor}</a> gemacht"
|
||||
"en": "Change made by <a href='https://openstreetmap.org/user/{_last_edit:contributor}' target='_blank'>{_last_edit:contributor}</a>"
|
||||
}
|
||||
},
|
||||
{
|
||||
"id": "theme",
|
||||
"render": {
|
||||
"en": "Change with theme <a href='https://mapcomplete.osm.be/{theme}'>{theme}</a>",
|
||||
"de": "Änderung mit Thema <a href='https://mapcomplete.osm.be/{theme}'>{theme}</a>"
|
||||
"en": "Change with theme <a href='https://mapcomplete.osm.be/{theme}'>{theme}</a>"
|
||||
},
|
||||
"mappings": [
|
||||
{
|
||||
"if": "theme~http.*",
|
||||
"then": {
|
||||
"en": "Change with <b>unofficial</b> theme <a href='https://mapcomplete.osm.be/theme.html?userlayout={theme}'>{theme}</a>",
|
||||
"de": "Änderung mit <b>inoffiziellem</b> Thema <a href='https://mapcomplete.osm.be/theme.html?userlayout={theme}'>{theme}</a>"
|
||||
"en": "Change with <b>unofficial</b> theme <a href='https://mapcomplete.osm.be/theme.html?userlayout={theme}'>{theme}</a>"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -338,8 +328,7 @@
|
|||
}
|
||||
],
|
||||
"question": {
|
||||
"en": "Themename contains {search}",
|
||||
"de": "Themenname enthält {search}"
|
||||
"en": "Themename contains {search}"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -355,8 +344,7 @@
|
|||
}
|
||||
],
|
||||
"question": {
|
||||
"en": "Made by contributor {search}",
|
||||
"de": "Erstellt von {search}"
|
||||
"en": "Made by contributor {search}"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -372,8 +360,7 @@
|
|||
}
|
||||
],
|
||||
"question": {
|
||||
"en": "<b>Not</b> made by contributor {search}",
|
||||
"de": "<b>Nicht</b> erstellt von {search}"
|
||||
"en": "<b>Not</b> made by contributor {search}"
|
||||
}
|
||||
}
|
||||
]
|
||||
|
@ -388,8 +375,7 @@
|
|||
{
|
||||
"id": "link_to_more",
|
||||
"render": {
|
||||
"en": "More statistics can be found <a href='https://github.com/pietervdvn/MapComplete/tree/develop/Docs/Tools/graphs' target='_blank'>here</a>",
|
||||
"de": "Weitere Statistiken finden Sie <a href='https://github.com/pietervdvn/MapComplete/tree/develop/Docs/Tools/graphs' target='_blank'>hier</a>"
|
||||
"en": "More statistics can be found <a href='https://github.com/pietervdvn/MapComplete/tree/develop/Docs/Tools/graphs' target='_blank'>here</a>"
|
||||
}
|
||||
},
|
||||
{
|
||||
|
|
|
@ -161,8 +161,8 @@ async function createManifest(layout: LayoutConfig, alreadyWritten: string[]): P
|
|||
console.log(icon)
|
||||
throw "Icon is not an svg for " + layout.id
|
||||
}
|
||||
const ogTitle = Translations.WT(layout.title).txt;
|
||||
const ogDescr = Translations.WT(layout.description ?? "").txt;
|
||||
const ogTitle = Translations.T(layout.title).txt;
|
||||
const ogDescr = Translations.T(layout.description ?? "").txt;
|
||||
|
||||
const manifest = {
|
||||
name: name,
|
||||
|
@ -186,8 +186,8 @@ async function createLandingPage(layout: LayoutConfig, manifest, whiteIcons, alr
|
|||
|
||||
Locale.language.setData(layout.language[0]);
|
||||
const targetLanguage = layout.language[0]
|
||||
const ogTitle = Translations.WT(layout.title).textFor(targetLanguage).replace(/"/g, '\\"');
|
||||
const ogDescr = Translations.WT(layout.shortDescription ?? "Easily add and edit geodata with OpenStreetMap").textFor(targetLanguage).replace(/"/g, '\\"');
|
||||
const ogTitle = Translations.T(layout.title).textFor(targetLanguage).replace(/"/g, '\\"');
|
||||
const ogDescr = Translations.T(layout.shortDescription ?? "Easily add and edit geodata with OpenStreetMap").textFor(targetLanguage).replace(/"/g, '\\"');
|
||||
let ogImage = layout.socialImage;
|
||||
let twitterImage = ogImage
|
||||
if (ogImage === LayoutConfig.defaultSocialImage && layout.official) {
|
||||
|
|
|
@ -18,7 +18,7 @@ function generateWikiEntry(layout: { hideFromOverview: boolean, id: string, shor
|
|||
|name= [https://mapcomplete.osm.be/${layout.id} ${layout.id}]
|
||||
|region= Worldwide
|
||||
|lang= ${languages}
|
||||
|descr= A MapComplete theme: ${Translations.WT(layout.shortDescription)
|
||||
|descr= A MapComplete theme: ${Translations.T(layout.shortDescription)
|
||||
.textFor("en")
|
||||
.replace("<a href='", "[[")
|
||||
.replace(/'>.*<\/a>/, "]]")
|
||||
|
|
Loading…
Reference in a new issue