Keep ordering from po file
This commit is contained in:
parent
8eb8f991da
commit
4a1eb36027
|
@ -17,7 +17,7 @@ class TranslationManager(models.Manager):
|
||||||
trans.update_from_blob(blob)
|
trans.update_from_blob(blob)
|
||||||
|
|
||||||
class UnitManager(models.Manager):
|
class UnitManager(models.Manager):
|
||||||
def update_from_unit(self, translation, unit):
|
def update_from_unit(self, translation, unit, pos):
|
||||||
'''
|
'''
|
||||||
Process translation toolkit unit and stores/updates database entry.
|
Process translation toolkit unit and stores/updates database entry.
|
||||||
'''
|
'''
|
||||||
|
@ -38,7 +38,7 @@ class UnitManager(models.Manager):
|
||||||
context = ctx)
|
context = ctx)
|
||||||
force = True
|
force = True
|
||||||
|
|
||||||
dbunit.update_from_unit(unit, force)
|
dbunit.update_from_unit(unit, pos, force)
|
||||||
return dbunit
|
return dbunit
|
||||||
|
|
||||||
def filter_type(self, rqtype):
|
def filter_type(self, rqtype):
|
||||||
|
|
|
@ -211,10 +211,10 @@ class Translation(models.Model):
|
||||||
|
|
||||||
# Load po file
|
# Load po file
|
||||||
store = self.get_store()
|
store = self.get_store()
|
||||||
for unit in store.units:
|
for pos, unit in enumerate(store.units):
|
||||||
if unit.istranslatable():
|
if unit.istranslatable():
|
||||||
continue
|
continue
|
||||||
newunit = Unit.objects.update_from_unit(self, unit)
|
newunit = Unit.objects.update_from_unit(self, unit, pos)
|
||||||
try:
|
try:
|
||||||
oldunits.remove(newunit.id)
|
oldunits.remove(newunit.id)
|
||||||
except:
|
except:
|
||||||
|
@ -296,18 +296,23 @@ class Unit(models.Model):
|
||||||
target = models.TextField(default = '', blank = True)
|
target = models.TextField(default = '', blank = True)
|
||||||
fuzzy = models.BooleanField(default = False, db_index = True)
|
fuzzy = models.BooleanField(default = False, db_index = True)
|
||||||
translated = models.BooleanField(default = False, db_index = True)
|
translated = models.BooleanField(default = False, db_index = True)
|
||||||
|
position = models.IntegerField(db_index = True)
|
||||||
|
|
||||||
objects = UnitManager()
|
objects = UnitManager()
|
||||||
|
|
||||||
def update_from_unit(self, unit, force):
|
class Meta:
|
||||||
|
ordering = ['position']
|
||||||
|
|
||||||
|
def update_from_unit(self, unit, pos, force):
|
||||||
location = ', '.join(unit.getlocations())
|
location = ', '.join(unit.getlocations())
|
||||||
flags = ', '.join(unit.typecomments)
|
flags = ', '.join(unit.typecomments)
|
||||||
target = join_plural(unit.target.strings)
|
target = join_plural(unit.target.strings)
|
||||||
fuzzy = unit.isfuzzy()
|
fuzzy = unit.isfuzzy()
|
||||||
translated = unit.istranslated()
|
translated = unit.istranslated()
|
||||||
comment = unit.getnotes()
|
comment = unit.getnotes()
|
||||||
if not force and location == self.location and flags == self.flags and target == self.target and fuzzy == self.fuzzy and translated == self.translated and comment == self.comment:
|
if not force and location == self.location and flags == self.flags and target == self.target and fuzzy == self.fuzzy and translated == self.translated and comment == self.comment and pos == self.position:
|
||||||
return
|
return
|
||||||
|
self.position = pos
|
||||||
self.location = location
|
self.location = location
|
||||||
self.flags = flags
|
self.flags = flags
|
||||||
self.target = target
|
self.target = target
|
||||||
|
|
Loading…
Reference in New Issue
Block a user