Make it possible to force refresh
This commit is contained in:
parent
07cc3e6328
commit
ee76af5ff4
@ -5,7 +5,7 @@ from lang.models import Language
|
||||
from util import is_plural, split_plural, join_plural, msg_checksum
|
||||
|
||||
class TranslationManager(models.Manager):
|
||||
def update_from_blob(self, subproject, code, path, blob):
|
||||
def update_from_blob(self, subproject, code, path, blob, force = False):
|
||||
'''
|
||||
Parses translation meta info and creates/updates translation object.
|
||||
'''
|
||||
@ -14,7 +14,7 @@ class TranslationManager(models.Manager):
|
||||
language = lang,
|
||||
subproject = subproject,
|
||||
filename = path)
|
||||
trans.update_from_blob(blob)
|
||||
trans.update_from_blob(blob, force)
|
||||
|
||||
class UnitManager(models.Manager):
|
||||
def update_from_unit(self, translation, unit, pos):
|
||||
|
@ -140,14 +140,14 @@ class SubProject(models.Model):
|
||||
# Get blobs for files
|
||||
return [(self.get_lang_code(f), f, tree[f]) for f in files]
|
||||
|
||||
def create_translations(self):
|
||||
def create_translations(self, force = False):
|
||||
'''
|
||||
Loads translations from git.
|
||||
'''
|
||||
blobs = self.get_translation_blobs()
|
||||
for code, path, blob in blobs:
|
||||
logger.info('processing %s', path)
|
||||
Translation.objects.update_from_blob(self, code, path, blob)
|
||||
Translation.objects.update_from_blob(self, code, path, blob, force)
|
||||
|
||||
def get_lang_code(self, path):
|
||||
'''
|
||||
@ -199,12 +199,12 @@ class Translation(models.Model):
|
||||
def get_store(self):
|
||||
return factory.getobject(os.path.join(self.subproject.get_path(), self.filename))
|
||||
|
||||
def update_from_blob(self, blob):
|
||||
def update_from_blob(self, blob, force = False):
|
||||
'''
|
||||
Updates translation data from blob.
|
||||
'''
|
||||
# Check if we're not already up to date
|
||||
if self.revision == blob.hexsha:
|
||||
if self.revision == blob.hexsha and not force:
|
||||
return
|
||||
|
||||
oldunits = set(self.unit_set.all().values_list('id', flat = True))
|
||||
|
Loading…
Reference in New Issue
Block a user