From 20e5ef761ed260bff29a6a8b32ee71b1d84bd492 Mon Sep 17 00:00:00 2001 From: svHvidsten Date: Fri, 6 Dec 2024 11:08:18 +0100 Subject: [PATCH] Added direction to languages, such that Arabic works (more) properly --- piggy/{static => }/data/language-data.json | 0 piggy/models.py | 215 +-------------------- piggy/templates/layout.html | 2 +- 3 files changed, 8 insertions(+), 209 deletions(-) rename piggy/{static => }/data/language-data.json (100%) diff --git a/piggy/static/data/language-data.json b/piggy/data/language-data.json similarity index 100% rename from piggy/static/data/language-data.json rename to piggy/data/language-data.json diff --git a/piggy/models.py b/piggy/models.py index 209a8b0..66130e8 100644 --- a/piggy/models.py +++ b/piggy/models.py @@ -1,210 +1,9 @@ -_LANGUAGES = { - "": {"name": "Norsk", "flag": "🇳🇴"}, # Default language - "aar": {"name": "Afaraf", "flag": "🇪🇷"}, # Eritrea - "abk": {"name": "Аҧсуа", "flag": "🇬🇪"}, # Georgia (Abkhazia) - "ace": {"name": "Bahsa Acèh", "flag": "🇮🇩"}, # Indonesia - "ach": {"name": "Lwo", "flag": "🇺🇬"}, # Uganda - "ada": {"name": "Adangme", "flag": "🇬🇭"}, # Ghana - "ady": {"name": "Адыгэбзэ", "flag": "🇷🇺"}, # Russia - "afr": {"name": "Afrikaans", "flag": "🇿🇦"}, # South Africa - "ain": {"name": "アイヌ・イタㇰ", "flag": "🇯🇵"}, # Japan - "aka": {"name": "Akan", "flag": "🇬🇭"}, # Ghana - "alb": {"name": "Shqip", "flag": "🇦🇱"}, # Albania - "amh": {"name": "አማርኛ", "flag": "🇪🇹"}, # Ethiopia - "ara": {"name": "العربية", "flag": "🇸🇦"}, # Saudi Arabia - "arg": {"name": "Aragonés", "flag": "🇪🇸"}, # Spain - "arm": {"name": "Հայերեն", "flag": "🇦🇲"}, # Armenia - "asm": {"name": "অসমীয়া", "flag": "🇮🇳"}, # India - "ava": {"name": "Авар мацӀ", "flag": "🇷🇺"}, # Russia - "ave": {"name": "avesta", "flag": "🏳️"}, # Historical language - "aym": {"name": "Aymar aru", "flag": "🇧🇴"}, # Bolivia - "aze": {"name": "Azərbaycanca", "flag": "🇦🇿"}, # Azerbaijan - "bak": {"name": "Башҡорт теле", "flag": "🇷🇺"}, # Russia - "bam": {"name": "Bamanankan", "flag": "🇲🇱"}, # Mali - "baq": {"name": "Euskara", "flag": "🇪🇸"}, # Spain - "bel": {"name": "Беларуская", "flag": "🇧🇾"}, # Belarus - "ben": {"name": "বাংলা", "flag": "🇧🇩"}, # Bangladesh - "bih": {"name": "भोजपुरी", "flag": "🇮🇳"}, # India - "bis": {"name": "Bislama", "flag": "🇻🇺"}, # Vanuatu - "bod": {"name": "བོད་ཡིག", "flag": "🇨🇳"}, # China (Tibet) - "bos": {"name": "Bosanski", "flag": "🇧🇦"}, # Bosnia and Herzegovina - "bre": {"name": "Brezhoneg", "flag": "🇫🇷"}, # France (Brittany) - "bul": {"name": "Български", "flag": "🇧🇬"}, # Bulgaria - "bur": {"name": "မြန်မာစာ", "flag": "🇲🇲"}, # Myanmar - "cat": {"name": "Català", "flag": "🇪🇸"}, # Spain - "ces": {"name": "Čeština", "flag": "🇨🇿"}, # Czech Republic - "cha": {"name": "Chamoru", "flag": "🇬🇺"}, # Guam - "che": {"name": "нохчийн мотт", "flag": "🇷🇺"}, # Russia (Chechnya) - "chi": {"name": "中文", "flag": "🇨🇳"}, # China - "chu": {"name": "Словѣньскъ", "flag": "🏳️"}, # Historical language - "chv": {"name": "Чӑвашла", "flag": "🇷🇺"}, # Russia - "cor": {"name": "Kernewek", "flag": "🏴󠁧󠁢󠁥󠁮󠁧󠁿"}, # England (Cornwall) - "cos": {"name": "Corsu", "flag": "🇫🇷"}, # France (Corsica) - "cre": {"name": "Nehiyaw", "flag": "🇨🇦"}, # Canada - "cym": {"name": "Cymraeg", "flag": "🏴󠁧󠁢󠁷󠁬󠁳󠁿"}, # Wales - "dan": {"name": "Dansk", "flag": "🇩🇰"}, # Denmark - "deu": {"name": "Deutsch", "flag": "🇩🇪"}, # Germany - "div": {"name": "ދިވެހި", "flag": "🇲🇻"}, # Maldives - "dut": {"name": "Nederlands", "flag": "🇳🇱"}, # Netherlands - "dzo": {"name": "རྫོང་ཁ", "flag": "🇧🇹"}, # Bhutan - "ell": {"name": "Ελληνικά", "flag": "🇬🇷"}, # Greece - "eng": {"name": "English", "flag": "🇬🇧"}, # United Kingdom - "epo": {"name": "Esperanto", "flag": "🏳️"}, # Constructed language - "est": {"name": "Eesti", "flag": "🇪🇪"}, # Estonia - "eus": {"name": "Euskara", "flag": "🇪🇸"}, # Spain - "ewe": {"name": "Eʋegbe", "flag": "🇹🇬"}, # Togo - "fao": {"name": "Føroyskt", "flag": "🇫🇴"}, # Faroe Islands - "fas": {"name": "فارسی", "flag": "🇮🇷"}, # Iran - "fij": {"name": "Na Vosa Vakaviti", "flag": "🇫🇯"}, # Fiji - "fin": {"name": "Suomi", "flag": "🇫🇮"}, # Finland - "fra": {"name": "Français", "flag": "🇫🇷"}, # France - "fre": {"name": "Français", "flag": "🇫🇷"}, # Also 'fra' - "fry": {"name": "Frysk", "flag": "🇳🇱"}, # Netherlands - "ful": {"name": "Fulfulde", "flag": "🇳🇬"}, # Nigeria - "geo": {"name": "ქართული", "flag": "🇬🇪"}, # Georgia - "ger": {"name": "Deutsch", "flag": "🇩🇪"}, # Also 'deu' - "gla": {"name": "Gàidhlig", "flag": "🏴󠁧󠁢󠁳󠁣󠁴󠁿"}, # Scotland - "gle": {"name": "Gaeilge", "flag": "🇮🇪"}, # Ireland - "glg": {"name": "Galego", "flag": "🇪🇸"}, # Spain - "glv": {"name": "Gaelg", "flag": "🇮🇲"}, # Isle of Man - "gre": {"name": "Ελληνικά", "flag": "🇬🇷"}, # Also 'ell' - "grn": {"name": "Avañe'ẽ", "flag": "🇵🇾"}, # Paraguay - "guj": {"name": "ગુજરાતી", "flag": "🇮🇳"}, # India - "hat": {"name": "Kreyòl ayisyen", "flag": "🇭🇹"}, # Haiti - "hau": {"name": "Hausa", "flag": "🇳🇬"}, # Nigeria - "heb": {"name": "עברית", "flag": "🇮🇱"}, # Israel - "her": {"name": "Otjiherero", "flag": "🇳🇦"}, # Namibia - "hin": {"name": "हिन्दी", "flag": "🇮🇳"}, # India - "hmo": {"name": "Hiri Motu", "flag": "🇵🇬"}, # Papua New Guinea - "hrv": {"name": "Hrvatski", "flag": "🇭🇷"}, # Croatia - "hun": {"name": "Magyar", "flag": "🇭🇺"}, # Hungary - "hye": {"name": "Հայերեն", "flag": "🇦🇲"}, # Armenia - "ibo": {"name": "Igbo", "flag": "🇳🇬"}, # Nigeria - "ice": {"name": "Íslenska", "flag": "🇮🇸"}, # Also 'isl' - "ido": {"name": "Ido", "flag": "🏳️"}, # Constructed language - "iii": {"name": "ꆈꌠ꒿ Nuosuhxop", "flag": "🇨🇳"}, # China - "iku": {"name": "ᐃᓄᒃᑎᑐᑦ", "flag": "🇨🇦"}, # Canada - "ind": {"name": "Bahasa Indonesia", "flag": "🇮🇩"}, # Indonesia - "ipk": {"name": "Iñupiatun", "flag": "🇺🇸"}, # United States (Alaska) - "isl": {"name": "Íslenska", "flag": "🇮🇸"}, # Iceland - "ita": {"name": "Italiano", "flag": "🇮🇹"}, # Italy - "jav": {"name": "Basa Jawa", "flag": "🇮🇩"}, # Indonesia - "jpn": {"name": "日本語", "flag": "🇯🇵"}, # Japan - "kal": {"name": "Kalaallisut", "flag": "🇬🇱"}, # Greenland - "kan": {"name": "ಕನ್ನಡ", "flag": "🇮🇳"}, # India - "kas": {"name": "कश्मीरी", "flag": "🇮🇳"}, # India - "kat": {"name": "ქართული", "flag": "🇬🇪"}, # Georgia - "kau": {"name": "Kanuri", "flag": "🇳🇬"}, # Nigeria - "kaz": {"name": "Қазақша", "flag": "🇰🇿"}, # Kazakhstan - "khm": {"name": "ភាសាខ្មែរ", "flag": "🇰🇭"}, # Cambodia - "kik": {"name": "Gĩkũyũ", "flag": "🇰🇪"}, # Kenya - "kin": {"name": "Ikinyarwanda", "flag": "🇷🇼"}, # Rwanda - "kir": {"name": "Кыргызча", "flag": "🇰🇬"}, # Kyrgyzstan - "kom": {"name": "Коми кыв", "flag": "🇷🇺"}, # Russia - "kon": {"name": "Kikongo", "flag": "🇨🇩"}, # DR Congo - "kor": {"name": "한국어", "flag": "🇰🇷"}, # South Korea - "kua": {"name": "Kuanyama", "flag": "🇳🇦"}, # Namibia - "kur": {"name": "Kurdî", "flag": "🇹🇷"}, # Turkey - "lao": {"name": "ພາສາລາວ", "flag": "🇱🇦"}, # Laos - "lat": {"name": "Latina", "flag": "🇻🇦"}, # Vatican City - "lav": {"name": "Latviešu", "flag": "🇱🇻"}, # Latvia - "lim": {"name": "Limburgs", "flag": "🇳🇱"}, # Netherlands - "lin": {"name": "Lingála", "flag": "🇨🇩"}, # DR Congo - "lit": {"name": "Lietuvių", "flag": "🇱🇹"}, # Lithuania - "ltz": {"name": "Lëtzebuergesch", "flag": "🇱🇺"}, # Luxembourg - "lub": {"name": "Kiluba", "flag": "🇨🇩"}, # DR Congo - "lug": {"name": "Luganda", "flag": "🇺🇬"}, # Uganda - "mac": {"name": "Македонски", "flag": "🇲🇰"}, # North Macedonia - "mah": {"name": "Kajin M̧ajeļ", "flag": "🇲🇭"}, # Marshall Islands - "mal": {"name": "മലയാളം", "flag": "🇮🇳"}, # India - "mar": {"name": "मराठी", "flag": "🇮🇳"}, # India - "mkd": {"name": "Македонски", "flag": "🇲🇰"}, # North Macedonia - "mlg": {"name": "Malagasy", "flag": "🇲🇬"}, # Madagascar - "mlt": {"name": "Malti", "flag": "🇲🇹"}, # Malta - "mon": {"name": "Монгол", "flag": "🇲🇳"}, # Mongolia - "mri": {"name": "Te Reo Māori", "flag": "🇳🇿"}, # New Zealand - "msa": {"name": "Bahasa Melayu", "flag": "🇲🇾"}, # Malaysia - "mya": {"name": "မြန်မာစာ", "flag": "🇲🇲"}, # Myanmar - "nau": {"name": "Ekakairũ Naoero", "flag": "🇳🇷"}, # Nauru - "nav": {"name": "Diné bizaad", "flag": "🇺🇸"}, # United States - "nbl": {"name": "isiNdebele", "flag": "🇿🇦"}, # South Africa - "nde": {"name": "isiNdebele", "flag": "🇿🇼"}, # Zimbabwe - "ndo": {"name": "Owambo", "flag": "🇳🇦"}, # Namibia - "nep": {"name": "नेपाली", "flag": "🇳🇵"}, # Nepal - "nld": {"name": "Nederlands", "flag": "🇳🇱"}, # Netherlands - "nno": {"name": "Norsk nynorsk", "flag": "🇳🇴"}, # Norway - "nob": {"name": "Norsk bokmål", "flag": "🇳🇴"}, # Norway - "nor": {"name": "Norsk", "flag": "🇳🇴"}, # Norway - "nya": {"name": "ChiCheŵa", "flag": "🇲🇼"}, # Malawi - "oci": {"name": "Occitan", "flag": "🇫🇷"}, # France - "oji": {"name": "ᐊᓂᔑᓈᐯᒧᐎᓐ", "flag": "🇨🇦"}, # Canada - "ori": {"name": "ଓଡ଼ିଆ", "flag": "🇮🇳"}, # India - "orm": {"name": "Afaan Oromoo", "flag": "🇪🇹"}, # Ethiopia - "oss": {"name": "Ирон æвзаг", "flag": "🇷🇺"}, # Russia - "pan": {"name": "ਪੰਜਾਬੀ", "flag": "🇮🇳"}, # India - "per": {"name": "فارسی", "flag": "🇮🇷"}, # Iran - "pli": {"name": "पाऴि", "flag": "🏳️"}, # Historical language - "pol": {"name": "Polski", "flag": "🇵🇱"}, # Poland - "por": {"name": "Português", "flag": "🇵🇹"}, # Portugal - "pus": {"name": "پښتو", "flag": "🇦🇫"}, # Afghanistan - "que": {"name": "Runa Simi", "flag": "🇵🇪"}, # Peru - "roh": {"name": "Rumantsch", "flag": "🇨🇭"}, # Switzerland - "ron": {"name": "Română", "flag": "🇷🇴"}, # Romania - "rum": {"name": "Română", "flag": "🇷🇴"}, # Also 'ron' - "run": {"name": "Kirundi", "flag": "🇧🇮"}, # Burundi - "rus": {"name": "Русский", "flag": "🇷🇺"}, # Russia - "sag": {"name": "Sängö", "flag": "🇨🇫"}, # Central African Republic - "san": {"name": "संस्कृतम्", "flag": "🇮🇳"}, # India - "sin": {"name": "සිංහල", "flag": "🇱🇰"}, # Sri Lanka - "slk": {"name": "Slovenčina", "flag": "🇸🇰"}, # Slovakia - "slo": {"name": "Slovenčina", "flag": "🇸🇰"}, # Also 'slk' - "slv": {"name": "Slovenščina", "flag": "🇸🇮"}, # Slovenia - "sme": {"name": "Davvisámegiella", "flag": "🇳🇴"}, # Norway - "smo": {"name": "Gagana Samoa", "flag": "🇼🇸"}, # Samoa - "sna": {"name": "ChiShona", "flag": "🇿🇼"}, # Zimbabwe - "snd": {"name": "سنڌي", "flag": "🇵🇰"}, # Pakistan - "som": {"name": "Soomaaliga", "flag": "🇸🇴"}, # Somalia - "sot": {"name": "Sesotho", "flag": "🇱🇸"}, # Lesotho - "spa": {"name": "Español", "flag": "🇪🇸"}, # Spain - "sqi": {"name": "Shqip", "flag": "🇦🇱"}, # Albania - "srd": {"name": "Sardu", "flag": "🇮🇹"}, # Italy - "srp": {"name": "Српски", "flag": "🇷🇸"}, # Serbia - "ssw": {"name": "SiSwati", "flag": "🇸🇿"}, # Eswatini - "sun": {"name": "Basa Sunda", "flag": "🇮🇩"}, # Indonesia - "swa": {"name": "Kiswahili", "flag": "🇰🇪"}, # Kenya - "swe": {"name": "Svenska", "flag": "🇸🇪"}, # Sweden - "tah": {"name": "Reo Tahiti", "flag": "🇵🇫"}, # French Polynesia - "tam": {"name": "தமிழ்", "flag": "🇮🇳"}, # India - "tat": {"name": "Татар теле", "flag": "🇷🇺"}, # Russia - "tel": {"name": "తెలుగు", "flag": "🇮🇳"}, # India - "tgk": {"name": "Тоҷикӣ", "flag": "🇹🇯"}, # Tajikistan - "tgl": {"name": "Tagalog", "flag": "🇵🇭"}, # Philippines - "tha": {"name": "ไทย", "flag": "🇹🇭"}, # Thailand - "tib": {"name": "བོད་ཡིག", "flag": "🇨🇳"}, # China (Tibet) - "tir": {"name": "ትግርኛ", "flag": "🇪🇷"}, # Eritrea - "ton": {"name": "faka Tonga", "flag": "🇹🇴"}, # Tonga - "tsn": {"name": "Setswana", "flag": "🇧🇼"}, # Botswana - "tso": {"name": "Xitsonga", "flag": "🇿🇦"}, # South Africa - "tuk": {"name": "Türkmençe", "flag": "🇹🇲"}, # Turkmenistan - "tur": {"name": "Türkçe", "flag": "🇹🇷"}, # Turkey - "twi": {"name": "Twi", "flag": "🇬🇭"}, # Ghana - "uig": {"name": "Uyƣurqə", "flag": "🇨🇳"}, # China - "ukr": {"name": "Українська", "flag": "🇺🇦"}, # Ukraine - "urd": {"name": "اردو", "flag": "🇵🇰"}, # Pakistan - "uzb": {"name": "Oʻzbek", "flag": "🇺🇿"}, # Uzbekistan - "ven": {"name": "Tshivenḓa", "flag": "🇿🇦"}, # South Africa - "vie": {"name": "Tiếng Việt", "flag": "🇻🇳"}, # Vietnam - "vol": {"name": "Volapük", "flag": "🏳️"}, # Constructed language - "wel": {"name": "Cymraeg", "flag": "🏴󠁧󠁢󠁷󠁬󠁳󠁿"}, # Wales - "wln": {"name": "Walon", "flag": "🇧🇪"}, # Belgium - "wol": {"name": "Wolof", "flag": "🇸🇳"}, # Senegal - "xho": {"name": "isiXhosa", "flag": "🇿🇦"}, # South Africa - "yid": {"name": "ייִדיש", "flag": "🏳️"}, # No specific country - "yor": {"name": "Yorùbá", "flag": "🇳🇬"}, # Nigeria - "zha": {"name": "Saɯ cueŋƅ", "flag": "🇨🇳"}, # China - "zho": {"name": "中文", "flag": "🇨🇳"}, # China - "zul": {"name": "isiZulu", "flag": "🇿🇦"}, # South Africa -} +import json +from pathlib import Path + +def get_languages(): + with open(Path("piggy/data/language-data.json"), "r", encoding="utf-8") as language_file: + return json.load(language_file) # Add key to all languages for ease of use -LANGUAGES = {k: {"key": k, **v} for k, v in _LANGUAGES.items()} +LANGUAGES = get_languages() diff --git a/piggy/templates/layout.html b/piggy/templates/layout.html index e63dc1e..2712383 100644 --- a/piggy/templates/layout.html +++ b/piggy/templates/layout.html @@ -15,7 +15,7 @@ {% block header %} {% endblock %} -
+
{% block base %} {% endblock %}