forked from MapComplete/MapComplete
Fix: fix #2183 by updating wikidata-sdk to latest wikibase-sdk
This commit is contained in:
parent
45fe5767e1
commit
021e5f2734
4 changed files with 54 additions and 24 deletions
|
@ -3,7 +3,6 @@
|
|||
* Some meta-info (e.g. RTL) is exported too
|
||||
*/
|
||||
|
||||
import * as wds from "wikidata-sdk"
|
||||
import { Utils } from "../src/Utils"
|
||||
import ScriptUtils from "./ScriptUtils"
|
||||
import { existsSync, readFileSync, writeFileSync } from "fs"
|
||||
|
@ -44,10 +43,10 @@ async function fetchRegularLanguages() {
|
|||
" ?lang wdt:P424 ?code. \n" + // Wikimedia language code seems to be close to the weblate entries
|
||||
' SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } \n' +
|
||||
"} "
|
||||
const url = wds.sparqlQuery(sparql)
|
||||
const url = Wikidata.wds.sparqlQuery(sparql)
|
||||
|
||||
// request the generated URL with your favorite HTTP request library
|
||||
const result = await Utils.downloadJson(url, { "User-Agent": "MapComplete script" })
|
||||
const result = await Utils.downloadJson<{results: {bindings: any[]}}>(url, { "User-Agent": "MapComplete script" })
|
||||
const bindings = <LanguageSpecResult[]>result.results.bindings
|
||||
|
||||
// Traditional chinese = 繁體中文 or 正體中文
|
||||
|
@ -97,9 +96,9 @@ async function fetchSpecial(id: number, code: string): Promise<LanguageSpecResul
|
|||
' SERVICE wikibase:label { bd:serviceParam wikibase:language "en". } \n' +
|
||||
"} "
|
||||
console.log("Special sparql:", sparql)
|
||||
const url = wds.sparqlQuery(sparql)
|
||||
const url = Wikidata.wds.sparqlQuery(sparql)
|
||||
|
||||
const result = await Utils.downloadJson(url, { "User-Agent": "MapComplete script" })
|
||||
const result = await Utils.downloadJson<{results: {bindings: any[]}}>(url, { "User-Agent": "MapComplete script" })
|
||||
const bindings = result.results.bindings
|
||||
bindings.forEach((binding) => (binding["code"] = { value: code }))
|
||||
return bindings
|
||||
|
@ -133,9 +132,9 @@ async function getOfficialLanguagesPerCountry(): Promise<Map<string, string[]>>
|
|||
?language wdt:P218 ?languageCode.
|
||||
SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
|
||||
}`
|
||||
const url = wds.sparqlQuery(sparql)
|
||||
const url = Wikidata.wds.sparqlQuery(sparql)
|
||||
|
||||
const result = await Utils.downloadJson(url, { "User-Agent": "MapComplete script" })
|
||||
const result = await Utils.downloadJson<{results: {bindings: any[]}}>(url, { "User-Agent": "MapComplete script" })
|
||||
const bindings: { countryCode: { value: string }; languageCode: { value: string } }[] =
|
||||
result.results.bindings
|
||||
for (const binding of bindings) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue