Handle string-arrays in android format and editor
offlate/formats/androidstrings.py
37 | 37 | def content(self): | |
38 | 38 | aresources = [] | |
39 | 39 | for entry in self.translation: | |
40 | - | if entry.type == 'string-array': | |
41 | - | index = 0 | |
42 | - | for item in entry.orig: | |
43 | - | aresources.append( | |
44 | - | AndroidStringsEntry( | |
45 | - | androidstringslib.parser.entry( | |
46 | - | 'string', entry.id + ':' + index, entry.orig[index], entry.dst[index]), | |
47 | - | entry, index)) | |
48 | - | index += 1 | |
49 | - | else: | |
50 | - | aresources.append(AndroidStringsEntry(entry)) | |
40 | + | aresources.append(AndroidStringsEntry(entry)) | |
51 | 41 | return aresources | |
52 | 42 | ||
53 | 43 | def save(self): |
offlate/formats/entry.py
42 | 42 | else: | |
43 | 43 | return list(self.msgstrs.items())[index][1] | |
44 | 44 | ||
45 | + | def isPlural(self): | |
46 | + | return len(self.msgstrs) > 1 | |
47 | + | ||
45 | 48 | class POEntry(Entry): | |
46 | 49 | def __init__(self, entry): | |
47 | 50 | msgids = [entry.msgid] | |
… | |||
86 | 89 | if self.parent is not None: | |
87 | 90 | self.parent.dst[self.index] = content | |
88 | 91 | ||
92 | + | def isPlural(self): | |
93 | + | return isinstance(self.msgstrs, dict) | |
94 | + | ||
89 | 95 | class AppstoreEntry(Entry): | |
90 | 96 | def __init__(self, filename, en, tr): | |
91 | 97 | Entry.__init__(self, [en], [tr], False, False) |
offlate/ui/editor.py
269 | 269 | if i == 0: | |
270 | 270 | focuser = form | |
271 | 271 | i=i+1 | |
272 | - | elif len(data.msgstrs) > 1: | |
272 | + | elif data.isPlural(): | |
273 | 273 | self.msgid = QTabWidget() | |
274 | 274 | self.msgstr = QTabWidget() | |
275 | 275 | singular = TagClickEdit() | |
… | |||
296 | 296 | if i == 0: | |
297 | 297 | focuser = form | |
298 | 298 | i=i+1 | |
299 | + | elif len(data.msgstrs) > 1: | |
300 | + | self.msgid = QTabWidget() | |
301 | + | self.msgstr = QTabWidget() | |
302 | + | i = 0 | |
303 | + | for msgid in data.msgids: | |
304 | + | edit = TagClickEdit() | |
305 | + | edit.setFont(QFont(font)) | |
306 | + | edit.setReadOnly(True) | |
307 | + | edit.setText(msgid) | |
308 | + | edit.createLinks() | |
309 | + | edit.anchorClicked.connect(self.copyTag) | |
310 | + | self.msgid.addTab(edit, str(i)) | |
311 | + | i=i+1 | |
312 | + | i = 0 | |
313 | + | for msgstr in data.msgstrs: | |
314 | + | form = SpellCheckEdit(self.project.lang) | |
315 | + | form.setFont(QFont(font)) | |
316 | + | form.setText(msgstr) | |
317 | + | form.textChanged.connect(self.modify) | |
318 | + | self.msgstr.addTab(form, str(i)) | |
319 | + | if i == 0: | |
320 | + | focuser = form | |
321 | + | i=i+1 | |
299 | 322 | else: | |
300 | 323 | self.msgid = TagClickEdit() | |
301 | 324 | self.msgid.setFont(QFont(font)) |