Commit 6574e8c2 authored by Sylvain Thénault's avatar Sylvain Thénault
Browse files

[i18ncube] do not crash if cube has nothing to translate

--HG--
branch : stable
parent b7fba311e8d0
......@@ -352,23 +352,23 @@ class UpdateTemplateCatalogCommand(Command):
def update_cubes_catalogs(cubes):
for cubedir in cubes:
toedit = []
if not isdir(cubedir):
print '-> ignoring %s that is not a directory.' % cubedir
continue
try:
toedit += update_cube_catalogs(cubedir)
toedit = update_cube_catalogs(cubedir)
except Exception:
import traceback
traceback.print_exc()
print '-> error while updating catalogs for cube', cubedir
else:
# instructions pour la suite
print '-> regenerated .po catalogs for cube %s.' % cubedir
print '\nYou can now edit the following files:'
print '* ' + '\n* '.join(toedit)
print ('When you are done, run "cubicweb-ctl i18ninstance '
'<yourinstance>" to see changes in your instances.')
if toedit:
print '-> regenerated .po catalogs for cube %s.' % cubedir
print '\nYou can now edit the following files:'
print '* ' + '\n* '.join(toedit)
print ('When you are done, run "cubicweb-ctl i18ninstance '
'<yourinstance>" to see changes in your instances.')
def update_cube_catalogs(cubedir):
import shutil
......@@ -376,7 +376,6 @@ def update_cube_catalogs(cubedir):
from logilab.common.fileutils import ensure_fs_mode
from logilab.common.shellutils import find, rm
from cubicweb.i18n import extract_from_tal, execute
toedit = []
cube = basename(normpath(cubedir))
tempdir = tempfile.mkdtemp()
print underline_title('Updating i18n catalogs for cube %s' % cube)
......@@ -421,8 +420,14 @@ def update_cube_catalogs(cubedir):
print '-> merging %i .pot files:' % len(potfiles)
execute('msgcat -o %s %s' % (potfile,
' '.join('"%s"' % f for f in potfiles)))
if not exists(potfile):
print 'no message catalog for cube', cube, 'nothing to translate'
# cleanup
rm(tempdir)
return ()
print '-> merging main pot file with existing translations:'
chdir('i18n')
toedit = []
for lang in LANGS:
print '-> language', lang
cubepo = '%s.po' % lang
......@@ -521,6 +526,7 @@ layout, and a full featured cube with "full" layout.',
# You should have received a copy of the GNU Lesser General Public License along
# with this program. If not, see <http://www.gnu.org/licenses/>.
''',
'GPL': '''\
# This program is free software: you can redistribute it and/or modify it under
# the terms of the GNU General Public License as published by the Free Software
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment