Fix support for Qt translation (and probably others)
Use po specific features only if they are available
This commit is contained in:
parent
a6595af47c
commit
16e6be4ccc
|
@ -21,7 +21,10 @@ class UnitManager(models.Manager):
|
||||||
'''
|
'''
|
||||||
Process translation toolkit unit and stores/updates database entry.
|
Process translation toolkit unit and stores/updates database entry.
|
||||||
'''
|
'''
|
||||||
src = join_plural(unit.source.strings)
|
if hasattr(unit.source, 'strings'):
|
||||||
|
src = join_plural(unit.source.strings)
|
||||||
|
else:
|
||||||
|
src = unit.source
|
||||||
ctx = unit.getcontext()
|
ctx = unit.getcontext()
|
||||||
checksum = msg_checksum(src, ctx)
|
checksum = msg_checksum(src, ctx)
|
||||||
import trans.models
|
import trans.models
|
||||||
|
|
|
@ -292,7 +292,11 @@ class Translation(models.Model):
|
||||||
need_save = False
|
need_save = False
|
||||||
for pounit in pounits:
|
for pounit in pounits:
|
||||||
if pounit.getcontext() == unit.context:
|
if pounit.getcontext() == unit.context:
|
||||||
if unit.target != join_plural(pounit.target.strings) or unit.fuzzy != pounit.isfuzzy():
|
if hasattr(pounit.target, 'strings'):
|
||||||
|
potarget = join_plural(pounit.target.strings)
|
||||||
|
else:
|
||||||
|
potarget = pounit.target
|
||||||
|
if unit.target != potarget or unit.fuzzy != pounit.isfuzzy():
|
||||||
pounit.markfuzzy(unit.fuzzy)
|
pounit.markfuzzy(unit.fuzzy)
|
||||||
if unit.is_plural():
|
if unit.is_plural():
|
||||||
pounit.settarget(unit.get_target_plurals())
|
pounit.settarget(unit.get_target_plurals())
|
||||||
|
@ -303,16 +307,17 @@ class Translation(models.Model):
|
||||||
break
|
break
|
||||||
if need_save:
|
if need_save:
|
||||||
author = '%s <%s>' % (request.user.get_full_name(), request.user.email)
|
author = '%s <%s>' % (request.user.get_full_name(), request.user.email)
|
||||||
po_revision_date = datetime.now().strftime('%Y-%m-%d %H:%M') + poheader.tzstring()
|
if hasattr(store, 'updateheader'):
|
||||||
|
po_revision_date = datetime.now().strftime('%Y-%m-%d %H:%M') + poheader.tzstring()
|
||||||
|
|
||||||
store.updateheader(
|
store.updateheader(
|
||||||
add = True,
|
add = True,
|
||||||
last_translator = author,
|
last_translator = author,
|
||||||
plural_forms = self.language.get_plural_form(),
|
plural_forms = self.language.get_plural_form(),
|
||||||
language = self.language.code,
|
language = self.language.code,
|
||||||
PO_Revision_Date = po_revision_date,
|
PO_Revision_Date = po_revision_date,
|
||||||
x_generator = 'Weblate %s' % trans.VERSION
|
x_generator = 'Weblate %s' % trans.VERSION
|
||||||
)
|
)
|
||||||
store.save()
|
store.save()
|
||||||
self.git_commit(author)
|
self.git_commit(author)
|
||||||
|
|
||||||
|
@ -355,8 +360,14 @@ class Unit(models.Model):
|
||||||
|
|
||||||
def update_from_unit(self, unit, pos, force):
|
def update_from_unit(self, unit, pos, force):
|
||||||
location = ', '.join(unit.getlocations())
|
location = ', '.join(unit.getlocations())
|
||||||
flags = ', '.join(unit.typecomments)
|
if hasattr(unit, 'typecomments'):
|
||||||
target = join_plural(unit.target.strings)
|
flags = ', '.join(unit.typecomments)
|
||||||
|
else:
|
||||||
|
flags = ''
|
||||||
|
if hasattr(unit.target, 'strings'):
|
||||||
|
target = join_plural(unit.target.strings)
|
||||||
|
else:
|
||||||
|
target = unit.target
|
||||||
fuzzy = unit.isfuzzy()
|
fuzzy = unit.isfuzzy()
|
||||||
translated = unit.istranslated()
|
translated = unit.istranslated()
|
||||||
comment = unit.getnotes()
|
comment = unit.getnotes()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user