Update android-strings-lib and add support for plural and string-arrays
guix.scm
189 | 189 | (method git-fetch) | |
190 | 190 | (uri (git-reference | |
191 | 191 | (url "https://framagit.org/tyreunom/python-android-strings-lib") | |
192 | - | (commit "0415535b125a64eb6da20a6b15ad92456e73ca8d"))) | |
192 | + | (commit "92d15a9a31a0d3184be01ce433ec74c2f426dc01"))) | |
193 | 193 | (file-name (git-file-name name version)) | |
194 | 194 | (sha256 | |
195 | - | (base32 | |
196 | - | "0icalva7a5w8a6qcrgkxkywckdqv8r5j5y9d5m6ln8bbk9s9fbls")))) | |
195 | + | (base32 | |
196 | + | "0q41vnh5q5phy36vnpfb8pr3zg9brwg2vqq72x2d8jh7yrdyrgdj")))) | |
197 | 197 | (build-system python-build-system) | |
198 | 198 | (arguments | |
199 | 199 | `(#:tests? #f)) |
offlate/formats/androidstrings.py
76 | 76 | return [self.enfilename, self.translationfilename] | |
77 | 77 | ||
78 | 78 | def reload(self): | |
79 | - | self.translation = androidstringslib.android(self.conf["template"], self.conf["file"]) | |
79 | + | self.translation = androidstringslib.android(self.conf["template"], self.conf["file"], self.conf['lang']) | |
80 | 80 | ||
81 | 81 | def translationFiles(self): | |
82 | 82 | return [self.translationfilename] |
offlate/formats/entry.py
65 | 65 | if entry.type == 'string': | |
66 | 66 | msgids = [entry.orig] | |
67 | 67 | msgstrs = [entry.dst] | |
68 | - | elif entry.type == 'plurals': | |
69 | - | msgid = entry.orig | |
68 | + | else: | |
69 | + | msgids = entry.orig | |
70 | 70 | msgstrs = entry.dst | |
71 | 71 | Entry.__init__(self, msgids, msgstrs, False, False) | |
72 | 72 | self.entry = entry |
offlate/ui/editor.py
98 | 98 | cont = True | |
99 | 99 | if not cont: | |
100 | 100 | continue | |
101 | - | item = QTreeWidgetItem([entry.msgids[0].replace('\n', ' '), | |
102 | - | entry.msgstrs[0].replace('\n', ' ')]) | |
101 | + | txt = None | |
102 | + | i = 0 | |
103 | + | while txt is None: | |
104 | + | txt = entry.msgids[i] if isinstance(entry.msgids, list) else \ | |
105 | + | list(entry.msgids.items())[i][1] | |
106 | + | i = i + 1 | |
107 | + | if i >= len(entry.msgids) and txt is None: | |
108 | + | txt = '' | |
109 | + | trans = None | |
110 | + | i = 0 | |
111 | + | while trans is None: | |
112 | + | trans = entry.msgstrs[i] if isinstance(entry.msgstrs, list) else \ | |
113 | + | list(entry.msgstrs.items())[i][1] | |
114 | + | i = i + 1 | |
115 | + | if i >= len(entry.msgstrs) and trans is None: | |
116 | + | trans = '' | |
117 | + | ||
118 | + | item = QTreeWidgetItem([txt.replace('\n', ' '), | |
119 | + | trans.replace('\n', ' ')]) | |
103 | 120 | if entry.isFuzzy(): | |
104 | 121 | item.setForeground(1, self.fuzzyColor) | |
105 | 122 | if not entry.isTranslated(): | |
… | |||
231 | 248 | font = "monospace" if self.monospace else "sans-serif" | |
232 | 249 | focuser = None | |
233 | 250 | ||
234 | - | if len(data.msgstrs) > 1: | |
235 | - | self.msgid = QTabWidget(); | |
236 | - | self.msgstr = QTabWidget(); | |
251 | + | if isinstance(data.msgstrs, dict): | |
252 | + | self.msgid = QTabWidget() | |
253 | + | self.msgstr = QTabWidget() | |
254 | + | for k in data.msgids: | |
255 | + | edit = TagClickEdit() | |
256 | + | edit.setFont(QFont(font)) | |
257 | + | edit.setReadOnly(True) | |
258 | + | edit.setText(data.msgids[k]) | |
259 | + | edit.createLinks() | |
260 | + | edit.anchorClicked.connect(self.copyTag) | |
261 | + | self.msgid.addTab(edit, self.tr(k)) | |
262 | + | i = 0 | |
263 | + | for k in data.msgstrs: | |
264 | + | form = SpellCheckEdit(self.project.lang) | |
265 | + | form.setFont(QFont(font)) | |
266 | + | form.setText(data.msgstrs[k]) | |
267 | + | form.textChanged.connect(self.modify) | |
268 | + | self.msgstr.addTab(form, self.tr(k)) | |
269 | + | if i == 0: | |
270 | + | focuser = form | |
271 | + | i=i+1 | |
272 | + | elif len(data.msgstrs) > 1: | |
273 | + | self.msgid = QTabWidget() | |
274 | + | self.msgstr = QTabWidget() | |
237 | 275 | singular = TagClickEdit() | |
238 | 276 | singular.setFont(QFont(font)) | |
239 | 277 | singular.setReadOnly(True) | |
… | |||
309 | 347 | ||
310 | 348 | def update(self, callback=None): | |
311 | 349 | self.project.save() | |
312 | - | print(callback) | |
313 | 350 | self.project.update(self.askmerge, callback) | |
314 | 351 | self.content = self.project.content() | |
315 | 352 | self.updateContent() |