1
0
mirror of https://github.com/ihabunek/toot synced 2024-12-23 07:27:12 +01:00

Show full language name

This commit is contained in:
Ivan Habunek 2022-12-11 23:26:15 +01:00
parent 92d6c399b1
commit 0ab0db048c
No known key found for this signature in database
GPG Key ID: CDBD63C43A30BB95
2 changed files with 188 additions and 6 deletions

View File

@ -3,6 +3,7 @@ import urwid
import webbrowser
from toot.utils import format_content
from toot.utils.language import language_name
from .utils import highlight_hashtags, parse_datetime, highlight_keys
from .widgets import SelectableText, SelectableColumns
@ -300,14 +301,18 @@ class StatusDetails(urwid.Pile):
yield ("pack", urwid.AttrWrap(urwid.Divider("-"), "gray"))
translated = status.show_translation and status.translated_from
translated_from = (
language_name(status.translated_from)
if status.show_translation and status.translated_from
else None
)
yield ("pack", urwid.Text([
("gray", "{} ".format(status.data["replies_count"])),
("yellow" if status.reblogged else "gray", "{} ".format(status.data["reblogs_count"])),
("yellow" if status.favourited else "gray", "{}".format(status.data["favourites_count"])),
("yellow" if translated else "gray", " · Translated from {} ".format(translated) if translated else ""),
("gray", " · {}".format(application) if application else ""),
("gray", f"{status.data['replies_count']} "),
("yellow" if status.reblogged else "gray", f"{status.data['reblogs_count']} "),
("yellow" if status.favourited else "gray", f"{status.data['favourites_count']}"),
("yellow", f" · Translated from {translated_from} ") if translated_from else "",
("gray", f" · {application}" if application else ""),
]))
# Push things to bottom

177
toot/utils/language.py Normal file
View File

@ -0,0 +1,177 @@
# Languages mapped by their ISO 639-1 code
# https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes
LANGUAGES = {
"ab": "Abkhazian",
"aa": "Afar",
"af": "Afrikaans",
"ak": "Akan",
"sq": "Albanian",
"am": "Amharic",
"ar": "Arabic",
"an": "Aragonese",
"hy": "Armenian",
"as": "Assamese",
"av": "Avaric",
"ae": "Avestan",
"ay": "Aymara",
"az": "Azerbaijani",
"bm": "Bambara",
"ba": "Bashkir",
"eu": "Basque",
"be": "Belarusian",
"bn": "Bengali",
"bi": "Bislama",
"bs": "Bosnian",
"br": "Breton",
"bg": "Bulgarian",
"my": "Burmese",
"ca": "Catalan",
"ch": "Chamorro",
"ce": "Chechen",
"ny": "Chichewa",
"zh": "Chinese",
"cu": "Old Slavonic",
"cv": "Chuvash",
"kw": "Cornish",
"co": "Corsican",
"cr": "Cree",
"hr": "Croatian",
"cs": "Czech",
"da": "Danish",
"dv": "Divehi",
"nl": "Dutch",
"en": "English",
"eo": "Estonian",
"ee": "Ewe",
"fo": "Faroese",
"fj": "Fijian",
"fi": "Finnish",
"fr": "French",
"fy": "Western Frisian",
"ff": "Fulah",
"gd": "Gaelic",
"gl": "Galician",
"lg": "Ganda",
"ka": "Georgian",
"de": "German",
"el": "Greek",
"kl": "Kalaallisut",
"gn": "Guarani",
"gu": "Gujarati",
"ht": "Haitian",
"ha": "Hausa",
"he": "Hebrew",
"hz": "Herero",
"hi": "Hiri Motu",
"hu": "Hungarian",
"is": "Icelandic",
"io": "Ido",
"ig": "Igbo",
"id": "Indonesian",
"ia": "Inupiaq",
"ga": "Irish",
"it": "Italian",
"ja": "Japanese",
"jv": "Javanese",
"kn": "Kannada",
"kr": "Kanuri",
"ks": "Kashmiri",
"kk": "Kazakh",
"km": "Central Khmer",
"ki": "Kikuyu",
"rw": "Kirghiz",
"kv": "Komi",
"kg": "Kongo",
"ko": "Korean",
"kj": "Kuanyama",
"ku": "Kurdish",
"lo": "Lao",
"la": "Latvian",
"li": "Limburgan",
"ln": "Lingala",
"lt": "Lithuanian",
"lu": "Luba-Katanga",
"lb": "Luxembourgish",
"mk": "Macedonian",
"mg": "Malagasy",
"ms": "Malay",
"ml": "Malayalam",
"mt": "Maltese",
"gv": "Manx",
"mi": "Maori",
"mr": "Marathi",
"mh": "Marshallese",
"mn": "Mongolian",
"na": "Nauru",
"nv": "Navajo",
"nd": "North Ndebele",
"nr": "South Ndebele",
"ng": "Nepali",
"no": "Norwegian",
"nb": "Norwegian Bokmål",
"nn": "Norwegian Nynorsk",
"ii": "Sichuan Yi",
"oc": "Occitan",
"oj": "Ojibwa",
"or": "Oriya",
"om": "Oromo",
"os": "Ossetian",
"pi": "Pali",
"ps": "Pashto",
"fa": "Persian",
"pl": "Polish",
"pt": "Portuguese",
"pa": "Punjabi",
"qu": "Quechua",
"ro": "Romanian",
"rm": "Romansh",
"rn": "Rundi",
"ru": "Russian",
"se": "Samoan",
"sg": "Sango",
"sa": "Sardinian",
"sr": "Serbian",
"sn": "Shona",
"sd": "Sindhi",
"si": "Sinhala",
"sk": "Slovak",
"sl": "Slovenian",
"so": "Somali",
"st": "Southern Sotho",
"es": "Spanish",
"su": "Sundanese",
"sw": "Swahili",
"ss": "Swati",
"sv": "Swedish",
"tl": "Tagalog",
"ty": "Tahitian",
"tg": "Tajik",
"ta": "Tamil",
"tt": "Tatar",
"te": "Telugu",
"th": "Thai",
"bo": "Tibetan",
"ti": "Tigrinya",
"to": "Tonga",
"ts": "Tsonga",
"tn": "Tswana",
"tr": "Turkish",
"tk": "Turkmen",
"tw": "Uighur",
"uk": "Ukrainian",
"ur": "Uzbek",
"ve": "Venda",
"vi": "Vietnamese",
"vo": "Walloon",
"cy": "Welsh",
"wo": "Wolof",
"xh": "Xhosa",
"yi": "Yiddish",
"yo": "Yoruba",
"za": "Zhuang",
"zu": "Zulu",
}
def language_name(code):
return LANGUAGES.get(code, code)