In Wikidata, this shows labels in English, and falls back to Russian if no English is available:

SERVICE wikibase:label {
 bd:serviceParam wikibase:language "en, ru" .

QUESTION: How to fall back to ANY language?

I could list all Wikidata languages ("en, ru, [... hundreds of languages ...]"), but that would be hard to maintain. Is there a more elegant solution?

Context: My app displays local monuments around you with a picture/name/map. Users have no idea what Wikidata is, so showing "ハチ公" or "ගල් විහාරය" is much better than showing "Q435398568", even if their phone is not set to these languages. Since the app is mostly used by locals and Wikidata usually has labels in the local language, even languages I have never heard about are often actually providing value to the users.

1 Answer 1


As optional get the label in English and in any language, then coalesce:

  (SAMPLE(COALESCE(?en_label, ?item_label)) as ?label)
  ?item wdt:P31 wd:Q22674925 .
  OPTIONAL {?item rdfs:label ?en_label . FILTER(LANG(?en_label) = "en")}
  OPTIONAL {?item rdfs:label ?item_label}
GROUP BY ?item

Example query

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.