forked from MapComplete/MapComplete
Fix: fix #2346
This commit is contained in:
parent
3d4eb321b2
commit
0fdf9448a9
2 changed files with 14 additions and 11 deletions
|
@ -1,6 +1,6 @@
|
|||
import { Utils } from "../../Utils"
|
||||
import { Store, UIEventSource } from "../UIEventSource"
|
||||
import { WBK } from "wikibase-sdk"
|
||||
import { SimplifiedClaims, WBK } from "wikibase-sdk"
|
||||
|
||||
export class WikidataResponse {
|
||||
public readonly id: string
|
||||
|
@ -54,14 +54,13 @@ export class WikidataResponse {
|
|||
}
|
||||
|
||||
static extractClaims(claimsJson: any): Map<string, Set<string>> {
|
||||
// @ts-ignore
|
||||
const simplified = Wikidata.wds.simplify.claims(claimsJson, {
|
||||
const simplified: SimplifiedClaims = Wikidata.wds.simplify.claims(claimsJson, {
|
||||
timeConverter: "simple-day",
|
||||
})
|
||||
|
||||
const claims = new Map<string, Set<string>>()
|
||||
for (const claimId in simplified) {
|
||||
const claimsList: any[] = simplified[claimId]
|
||||
const claimsList = simplified[claimId]
|
||||
claims.set(claimId, new Set(claimsList))
|
||||
}
|
||||
return claims
|
||||
|
@ -439,6 +438,9 @@ export default class Wikidata {
|
|||
return new WikidataLexeme(response).asWikidataResponse()
|
||||
}
|
||||
|
||||
return WikidataResponse.fromJson(response)
|
||||
const resp: WikidataResponse = WikidataResponse.fromJson(response)
|
||||
// 'mul' is the fallback language for wikidata, see https://source.mapcomplete.org/MapComplete/MapComplete/issues/2346
|
||||
resp.labels.set("*", resp.labels.get("mul"))
|
||||
return resp
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,16 +165,17 @@ export class Translation extends BaseUIElement {
|
|||
* Which language will be effectively used for the given language of choice?
|
||||
*/
|
||||
public actualLanguage(language: string): "*" | string | undefined {
|
||||
if (this.translations["*"]) {
|
||||
return "*"
|
||||
}
|
||||
|
||||
const txt = this.translations[language]
|
||||
if (txt === undefined && this._strictLanguages) {
|
||||
return undefined
|
||||
}
|
||||
if (txt !== undefined) {
|
||||
return language
|
||||
}
|
||||
if (this._strictLanguages) {
|
||||
return undefined
|
||||
}
|
||||
if (this.translations["*"]) {
|
||||
return "*"
|
||||
}
|
||||
if (this.translations["en"] !== undefined) {
|
||||
return "en"
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue