Prepare stub for actually loading po file

This commit is contained in:
Michal Čihař 2012-02-27 16:29:32 +01:00
parent 76ae1a508b
commit 6538ce2192
2 changed files with 12 additions and 2 deletions

View File

@ -7,11 +7,10 @@ class TranslationManager(models.Manager):
'''
Parses translation meta info and creates/updates translation object.
'''
print code
lang = Language.objects.get(code = code)
trans, created = self.get_or_create(
language = lang,
subproject = subproject,
filename = path)
print trans
trans.update_from_blob(blob)

View File

@ -161,6 +161,17 @@ class Translation(models.Model):
def __unicode__(self):
return '%s@%s' % (self.language.name, self.subproject.__unicode__())
def update_from_blob(self, blob):
'''
Updates translation data from blob.
'''
# Check if we're not already up to date
if self.revision == blob.hexsha:
return
oldunits = set(self.unit_set.all().values_list('id', flat = True))
class Unit(models.Model):
translation = models.ForeignKey(Translation)
location = models.TextField()