File tree 1 file changed +16
-9
lines changed
1 file changed +16
-9
lines changed Original file line number Diff line number Diff line change @@ -160,15 +160,22 @@ def get_qt_translations(languages):
160
160
for type in ["mapeditor" , "launcher" ]:
161
161
count_translated = 0
162
162
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
172
179
data_type [type ] = {"ratio" : ratio , "count_translated" : count_translated , "count_untranslated" : count_untranslated }
173
180
data [language ] = data_type
174
181
return data
You can’t perform that action at this time.
0 commit comments