Skip to content

Commit d0a0d69

Browse files
authored
Improve mozl10n code, update requirements (#45)
1 parent b1d9c48 commit d0a0d69

File tree

4 files changed

+31
-27
lines changed

4 files changed

+31
-27
lines changed

.github/requirements.txt

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
compare-locales==9.0.*
2-
jsonschema==4.23.*
3-
lxml==5.3.*
4-
moz-l10n==0.6.0
5-
polib==1.2.0
6-
requests==2.32.3
1+
compare-locales~=9.0.0
2+
jsonschema~=4.23.0
3+
lxml~=5.3.0
4+
moz-l10n~=0.6.1
5+
polib~=1.2.0
6+
requests~=2.32.0

l10n/android_l10n.py

+12-9
Original file line numberDiff line numberDiff line change
@@ -63,20 +63,23 @@ def extractStringsToml(self):
6363
if not locales:
6464
print("No locales defined in the project configuration.")
6565

66+
all_files = [
67+
(ref_path, tgt_path)
68+
for (ref_path, tgt_path), _ in project_config_paths.all().items()
69+
]
6670
for locale in locales:
6771
print(f"Extracting strings for locale: {locale}.")
68-
file_list = [
69-
(
70-
os.path.abspath(
71-
tgt_path.format(android_locale=get_android_locale(locale))
72-
),
73-
os.path.abspath(ref_path.format(android_locale=None)),
72+
locale_files = [
73+
(os.path.abspath(ref_path), os.path.abspath(tgt_path))
74+
for (ref_path, raw_tgt_path) in all_files
75+
if os.path.exists(
76+
tgt_path := project_config_paths.format_target_path(
77+
raw_tgt_path, locale
78+
)
7479
)
75-
for (ref_path, tgt_path), locales in project_config_paths.all().items()
76-
if locale in locales
7780
]
7881

79-
for l10n_file, ref_file in file_list:
82+
for ref_file, l10n_file in locale_files:
8083
# Ignore missing files in locale
8184
if not os.path.exists(l10n_file):
8285
# print(f"Ignored missing file for {locale}: {l10n_file}")

l10n/exceptions/focus_android.json

+1-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,6 @@
11
{
22
"HTML": {
3-
"locales": {
4-
"it": [
5-
"app/src/main/res/values/strings.xml:your_rights_content5"
6-
]
7-
},
3+
"locales": {},
84
"strings": []
95
},
106
"ellipsis": {

l10n/fluent_l10n.py

+12-7
Original file line numberDiff line numberDiff line change
@@ -119,18 +119,23 @@ def extractStringsToml(self):
119119

120120
read_references = []
121121

122+
all_files = [
123+
(ref_path, tgt_path)
124+
for (ref_path, tgt_path), _ in project_config_paths.all().items()
125+
]
122126
for locale in locales:
123127
print(f"Extracting strings for locale: {locale}.")
124-
file_list = [
125-
(
126-
os.path.abspath(tgt_path.format(locale=locale)),
127-
os.path.abspath(ref_path.format(locale=None)),
128+
locale_files = [
129+
(os.path.abspath(ref_path), os.path.abspath(tgt_path))
130+
for (ref_path, raw_tgt_path) in all_files
131+
if os.path.exists(
132+
tgt_path := project_config_paths.format_target_path(
133+
raw_tgt_path, locale
134+
)
128135
)
129-
for (ref_path, tgt_path), locales in project_config_paths.all().items()
130-
if locale in locales
131136
]
132137

133-
for l10n_file, ref_file in file_list:
138+
for ref_file, l10n_file in locale_files:
134139
# Ignore missing files in locale
135140
if not os.path.exists(l10n_file):
136141
# print(f"Ignored missing file for {locale}: {l10n_file}")

0 commit comments

Comments
 (0)