Fix ts item update

Julien LepillerSat Aug 31 13:33:28+0200 2019

da2c44d

Fix ts item update

offlate/formats/entry.py

118118
            if child.tag == "translation":
119119
                if numerus:
120120
                    i=0
121+
                    self.fuzzy = False
121122
                    for form in child:
122123
                        if i == index:
123124
                            form.text = content
124-
                            break
125+
                        if form.text == '':
126+
                            self.fuzzy = True
125127
                        i = i + 1
126128
                else:
127129
                    child.text = content
130+
                    self.fuzzy = content == ""

offlate/formats/ts.py

267267
                        for child in item:
268268
                            if child.tag == "translation":
269269
                                if numerus:
270-
                                    i = 0
271-
                                    for form in child:
272-
                                        form.text = msgstrs[i]
273-
                                        i += 1
270+
                                    child.clear()
271+
                                    unfinished = False
272+
                                    for i in range(0, int(get_nplurals(self.conf['lang']))):
273+
                                        e = ET.Element('numerusform')
274+
                                        e.text = msgstrs[i]
275+
                                        child.append(e)
276+
                                        unfinished = unfinished or msgstrs[i] == ''
277+
                                    if unfinished:
278+
                                        child.set('type', 'unfinished')
274279
                                else:
280+
                                    if msgstrs[0] != "":
281+
                                        child.clear()
282+
                                    else:
283+
                                        child.set('type', 'unfinished')
275284
                                    child.text = msgstrs[0]
276285
                                break
277286
            root.append(context)