-
Beta Was this translation helpful? Give feedback.
Replies: 4 comments
-
Could you elaborate what you exactly want? What do you mean by “response language”? |
Beta Was this translation helpful? Give feedback.
-
Beta Was this translation helpful? Give feedback.
-
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 >>> type(earth.label)
<class 'wikidata.multilingual.MultilingualText'>
>>> type(earth.description)
<class 'wikidata.multilingual.MultilingualText'> Actually, >>> earth.label['en']
'Earth'
>>> earth.label['fr']
'Terre'
>>> earth.label['zh']
'地球'
>>> earth.description['en']
'third planet from the Sun in the Solar System'
>>> earth.description['fr']
'troisième planète à partir du Soleil dans le système solaire'
>>> earth.description['zh']
'太陽系中距離太陽第三近的行星' |
Beta Was this translation helpful? Give feedback.
-
Thanks, that was easy!!!
From: Hong Minhee (洪 民憙) ***@***.***>
Sent: Tuesday, 1 November 2022 14:16
To: dahlia/wikidata ***@***.***>
Cc: MatsGej ***@***.***>; Author ***@***.***>
Subject: Re: [dahlia/wikidata] How do I set the response language? (Discussion #52)
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 corresponding texts:
>> earth.label['en']
'Earth'
>> earth.label['fr']
'Terre'
>> earth.label['zh']
'地球'
>> earth.description['en']
'third planet from the Sun in the Solar System'
>> earth.description['fr']
'troisième planète à partir du Soleil dans le système solaire'
>> earth.description['zh']
'太陽系中距離太陽第三近的行星'
—
Reply to this email directly, view it on GitHub<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fdahlia%2Fwikidata%2Fdiscussions%2F52%23discussioncomment-4027454&data=05%7C01%7C%7Ca738c71162ac43e04a3c08dabc0b2d5d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638029053426244276%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=FH81SFDgBNd%2FmXG%2BsG7yjdPYmEVTXNNGufXuhfNOwAA%3D&reserved=0>, or unsubscribe<https://nam12.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FALF63EYIJOODZCK4U4GQZRLWGEJXZANCNFSM6AAAAAARUBPIQA&data=05%7C01%7C%7Ca738c71162ac43e04a3c08dabc0b2d5d%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C638029053426244276%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000%7C%7C%7C&sdata=3182xR%2Fc9sviZizHZMufQMl8p%2FUxpZKK7M5XPzQJO2w%3D&reserved=0>.
You are receiving this because you authored the thread.Message ID: ***@***.******@***.***>>
|
Beta Was this translation helpful? Give feedback.
Entity objects contain all languages besides English. Let me elaborate with a demo session:
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 notstr
:Actually,
MultilingualText
is more similar to dictionaries than strings, because there mappings of language tags to…