Skip to content

How do I set the response language? #52

Answered by dahlia
MatsGej asked this question in Q&A
Discussion options

You must be logged in to vote

Entity objects contain all languages besides English. Let me elaborate with a demo session:

>>> from wikidata.client import Client
>>> client = Client()
>>> earth = client.get('Q2')
>>> earth.label
m'Earth'
>>> earth.description
m'third planet from the Sun in the Solar System'

Note that these strings have prefix m. The prefix means these are multilingual strings. If you look at the type of them you could notice these are not str:

>>> type(earth.label)
<class 'wikidata.multilingual.MultilingualText'>
>>> type(earth.description)
<class 'wikidata.multilingual.MultilingualText'>

Actually, MultilingualText is more similar to dictionaries than strings, because there mappings of language tags to…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by dahlia
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants
Converted from issue

This discussion was converted from issue #51 on November 01, 2022 13:12.