@@ -37,11 +37,17 @@ def load_params(self, params):
37
37
38
38
def has_change (self , orecord , erecord ):
39
39
for language in self .languages :
40
- olang = orecord .get (language , False )
41
- elang = erecord .get (language , False )
42
- if olang is False or elang is False :
40
+ olang = orecord .get (language , {})
41
+ elang = erecord .get (language , {})
42
+ if not elang :
43
+ # This language is neither being edited nor deleted (deletion
44
+ # would send an "edit" with value ⌫ , aka `BaseAction.DELETE`)
45
+ continue
46
+ if not olang :
47
+ # A new language is always a change
43
48
return True
44
- if self .record_repr (olang ) != self .record_repr (elang ):
49
+ if olang .get ('value' ) != elang .get ('value' ):
50
+ # An existing language has translation text that has changed
45
51
return True
46
52
return False
47
53
@@ -180,8 +186,21 @@ def engines(self):
180
186
yield (manual_name , manual_engine )
181
187
182
188
def record_repr (self , record ):
189
+ # TODO: Make sure this method is sensible. Some places, e.g.
190
+ # `BaseAction.is_auto_request()`, expect this method to return a
191
+ # single string; however, multiple translations cannot be represented
192
+ # adequately this way.
193
+ # Cope with this by returning a single string if there is only one
194
+ # translation, matching the previous behavior. If there is more than
195
+ # one translation, return a dictionary of
196
+ # `{'lang1': 'translation1','lang2': 'translation2', …}`.
197
+
183
198
if len (record .keys ()) == 1 :
184
199
return [* record .values ()][0 ].get ('value' )
200
+ return {
201
+ lang : lang_record .get ('value' )
202
+ for lang , lang_record in record .items ()
203
+ }
185
204
186
205
def auto_request_repr (self , erecord ):
187
206
lang_code = [* erecord .values ()][0 ]['languageCode' ]
0 commit comments