From 76f826dc725ed971e4797cb98e1db92e61174dc1 Mon Sep 17 00:00:00 2001 From: Marcin Koziej Date: Wed, 4 Apr 2012 14:32:45 +0200 Subject: [PATCH] handle null fields in modeltranslation use basename of zip file as directory name --- .../management/commands/translation2po.py | 9 +++++++-- apps/wolnelektury_core/management/commands/localepack.py | 2 +- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/apps/modeltranslation/management/commands/translation2po.py b/apps/modeltranslation/management/commands/translation2po.py index 57ef7fecf..09eec1a65 100644 --- a/apps/modeltranslation/management/commands/translation2po.py +++ b/apps/modeltranslation/management/commands/translation2po.py @@ -115,9 +115,13 @@ class Command(BaseCommand): po = make_po(cur_lang) pofiles[cur_lang] = po + k = getattr(obj, '%s_%s' % (fld, settings.LANGUAGE_CODE)) + if k is None: k = '' + v = getattr(obj, locfld) + if v is None: v = '' entry = polib.POEntry( - msgid=getattr(obj, '%s_%s' % (fld, settings.LANGUAGE_CODE)), - msgstr=getattr(obj, locfld), + msgid=k, + msgstr=v, occurrences=[('%s/%s/%s' % (appname, md.__name__, locfld), obj.id)]) po.append(entry) @@ -125,4 +129,5 @@ class Command(BaseCommand): for lng, po in pofiles.items(): try: os.makedirs(os.path.join(directory, lng)) except OSError: pass + print lng, options po.save(os.path.join(directory, lng, '%s.po' % options['poname'])) diff --git a/apps/wolnelektury_core/management/commands/localepack.py b/apps/wolnelektury_core/management/commands/localepack.py index 5d8ec870d..146cd3182 100644 --- a/apps/wolnelektury_core/management/commands/localepack.py +++ b/apps/wolnelektury_core/management/commands/localepack.py @@ -167,7 +167,7 @@ class Command(BaseCommand): raise NotImplementedError('Sorry. Only zip format supported at the moment.') tmp_dir = tempfile.mkdtemp('-wl-locale') - out_dir = os.path.join(tmp_dir, packname) + out_dir = os.path.join(tmp_dir, packname_b) os.mkdir(out_dir) try: -- 2.20.1