Fix handling modifications to plural android strings

Julien LepillerSun Jan 12 04:20:00+0100 2020

8376f23

Fix handling modifications to plural android strings

offlate/formats/entry.py

3737
        self.msgstrs[index] = content
3838
3939
    def get(self, index):
40-
        return self.msgstrs[index]
40+
        if isinstance(self.msgstrs, list):
41+
            return self.msgstrs[index]
42+
        else:
43+
            return list(self.msgstrs.items())[index][1]
4144
4245
class POEntry(Entry):
4346
    def __init__(self, entry):

offlate/ui/editor.py

322322
            item.setText(1, msgstr.replace('\n', ' '))
323323
        else:
324324
            i = 0
325-
            for msgstr in data.msgstrs:
326-
                data.update(i, self.msgstr.widget(i).toPlainText())
325+
            for msgstr in (data.msgstrs if isinstance(data.msgstrs, list) else \
326+
                                    list(data.msgstrs.keys())):
327+
                data.update(i if isinstance(data.msgstrs, list) else msgstr,
328+
                        self.msgstr.widget(i).toPlainText())
327329
                i=i+1
328330
            item.setText(1, data.get(0).replace('\n', ' '))
329331
        item.setForeground(1, QBrush())