-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathpycountry.patch
51 lines (45 loc) · 1.56 KB
/
pycountry.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
From f75d41db12f61363eee1097d2c1f63993a6d645c Mon Sep 17 00:00:00 2001
From: Danial Behzadi <[email protected]>
Date: Sun, 15 Dec 2024 21:31:38 +0330
Subject: [PATCH] patch pycountry.
---
src/config.py | 28 +++++++++++++++++++---------
1 file changed, 19 insertions(+), 9 deletions(-)
diff --git a/src/config.py b/src/config.py
index d64f44d..9936ce5 100644
--- a/src/config.py
+++ b/src/config.py
@@ -13,15 +13,25 @@ import pycountry
from gi.repository import Gio
-# Get the user's locale
-language = os.environ.get("LANG", "en_US.UTF-8").split(".")[0]
-countries_l10n = gettext.translation(
- "iso3166-1", pycountry.LOCALES_DIR, [language]
-)
+countries = [
+ pycountry.countries.get(alpha_2=code)
+ for code in ("ca", "ch", "de", "es", "gb", "it", "fr", "nl", "se", "us")
+]
+
+try:
+ language = os.environ.get("LANG", "en_US.UTF-8").split(".")[0]
+ countries_l10n = gettext.translation(
+ "iso3166-1", pycountry.LOCALES_DIR, [language]
+ )
+ NODES = {
+ country: f"{countries_l10n.gettext(country.name)} {country.flag}"
+ for country in countries
+ }
+# If pycountry does not provide country translations for the language
+except FileNotFoundError:
+ NODES = {
+ country: f"{country.name} {country.flag}" for country in countries
+ }
COMMAND = "tractor"
DCONF = Gio.Settings.new("org.tractor")
-NODES = {}
-for code in ("ca", "ch", "de", "es", "gb", "it", "fr", "nl", "se", "us"):
- country = pycountry.countries.get(alpha_2=code)
- NODES[code] = countries_l10n.gettext(country.name) + " " + country.flag
--
2.45.2