wikidata.multilingual — Multilingual texts

class wikidata.multilingual.MonolingualText

Locale-denoted text. It’s almost equivalent to str (and indeed subclasses str) except that it has two more attribute: locale and locale_code that denote what language the text is written in.


(Locale) The language (locale) that the text is written in.

locale_code = None

(str) The code of locale.

wikidata.multilingual.normalize_locale_code(locale: typing.Union[babel.core.Locale, str]) → str

Determine the normalized locale code string.

>>> normalize_locale_code('ko-kr')
>>> normalize_locale_code('zh_TW')
>>> normalize_locale_code(Locale.parse('en_US'))