Skip to content

Commit 58eafaa

Browse files
authored
fix qt
1 parent bd3df6c commit 58eafaa

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

.github/update.py

+16-9
Original file line numberDiff line numberDiff line change
@@ -160,15 +160,22 @@ def get_qt_translations(languages):
160160
for type in ["mapeditor", "launcher"]:
161161
count_translated = 0
162162
count_untranslated = 0
163-
tmp_str = urllib.request.urlopen("https://raw.githubusercontent.com/vcmi/vcmi/develop/" + type + "/translation/" + language + ".ts").read()
164-
root = ET.fromstring(tmp_str)
165-
for item_context in root.iter('context'):
166-
for item_message in item_context.iter('message'):
167-
if list(item_message.iter('translation'))[0].get("type") == None:
168-
count_translated += 1
169-
else:
170-
count_untranslated += 1
171-
ratio = (count_translated) / (count_translated + count_untranslated)
163+
try:
164+
tmp_str = urllib.request.urlopen("https://raw.githubusercontent.com/vcmi/vcmi/develop/" + type + "/translation/" + language + ".ts").read()
165+
except:
166+
tmp_str = ""
167+
if tmp_str != "":
168+
root = ET.fromstring(tmp_str)
169+
for item_context in root.iter('context'):
170+
for item_message in item_context.iter('message'):
171+
if list(item_message.iter('translation'))[0].get("type") == None:
172+
count_translated += 1
173+
else:
174+
count_untranslated += 1
175+
if (count_translated + count_untranslated) > 0:
176+
ratio = (count_translated) / (count_translated + count_untranslated)
177+
else:
178+
ratio = 0
172179
data_type[type] = {"ratio": ratio, "count_translated": count_translated, "count_untranslated": count_untranslated}
173180
data[language] = data_type
174181
return data

0 commit comments

Comments
 (0)