350 update_cubes_catalogs(cubes) |
350 update_cubes_catalogs(cubes) |
351 |
351 |
352 |
352 |
353 def update_cubes_catalogs(cubes): |
353 def update_cubes_catalogs(cubes): |
354 for cubedir in cubes: |
354 for cubedir in cubes: |
355 toedit = [] |
|
356 if not isdir(cubedir): |
355 if not isdir(cubedir): |
357 print '-> ignoring %s that is not a directory.' % cubedir |
356 print '-> ignoring %s that is not a directory.' % cubedir |
358 continue |
357 continue |
359 try: |
358 try: |
360 toedit += update_cube_catalogs(cubedir) |
359 toedit = update_cube_catalogs(cubedir) |
361 except Exception: |
360 except Exception: |
362 import traceback |
361 import traceback |
363 traceback.print_exc() |
362 traceback.print_exc() |
364 print '-> error while updating catalogs for cube', cubedir |
363 print '-> error while updating catalogs for cube', cubedir |
365 else: |
364 else: |
366 # instructions pour la suite |
365 # instructions pour la suite |
367 print '-> regenerated .po catalogs for cube %s.' % cubedir |
366 if toedit: |
368 print '\nYou can now edit the following files:' |
367 print '-> regenerated .po catalogs for cube %s.' % cubedir |
369 print '* ' + '\n* '.join(toedit) |
368 print '\nYou can now edit the following files:' |
370 print ('When you are done, run "cubicweb-ctl i18ninstance ' |
369 print '* ' + '\n* '.join(toedit) |
371 '<yourinstance>" to see changes in your instances.') |
370 print ('When you are done, run "cubicweb-ctl i18ninstance ' |
|
371 '<yourinstance>" to see changes in your instances.') |
372 |
372 |
373 def update_cube_catalogs(cubedir): |
373 def update_cube_catalogs(cubedir): |
374 import shutil |
374 import shutil |
375 import tempfile |
375 import tempfile |
376 from logilab.common.fileutils import ensure_fs_mode |
376 from logilab.common.fileutils import ensure_fs_mode |
377 from logilab.common.shellutils import find, rm |
377 from logilab.common.shellutils import find, rm |
378 from cubicweb.i18n import extract_from_tal, execute |
378 from cubicweb.i18n import extract_from_tal, execute |
379 toedit = [] |
|
380 cube = basename(normpath(cubedir)) |
379 cube = basename(normpath(cubedir)) |
381 tempdir = tempfile.mkdtemp() |
380 tempdir = tempfile.mkdtemp() |
382 print underline_title('Updating i18n catalogs for cube %s' % cube) |
381 print underline_title('Updating i18n catalogs for cube %s' % cube) |
383 chdir(cubedir) |
382 chdir(cubedir) |
384 if exists(join('i18n', 'entities.pot')): |
383 if exists(join('i18n', 'entities.pot')): |
419 potfiles.append(tmppotfile) |
418 potfiles.append(tmppotfile) |
420 potfile = join(tempdir, 'cube.pot') |
419 potfile = join(tempdir, 'cube.pot') |
421 print '-> merging %i .pot files:' % len(potfiles) |
420 print '-> merging %i .pot files:' % len(potfiles) |
422 execute('msgcat -o %s %s' % (potfile, |
421 execute('msgcat -o %s %s' % (potfile, |
423 ' '.join('"%s"' % f for f in potfiles))) |
422 ' '.join('"%s"' % f for f in potfiles))) |
|
423 if not exists(potfile): |
|
424 print 'no message catalog for cube', cube, 'nothing to translate' |
|
425 # cleanup |
|
426 rm(tempdir) |
|
427 return () |
424 print '-> merging main pot file with existing translations:' |
428 print '-> merging main pot file with existing translations:' |
425 chdir('i18n') |
429 chdir('i18n') |
|
430 toedit = [] |
426 for lang in LANGS: |
431 for lang in LANGS: |
427 print '-> language', lang |
432 print '-> language', lang |
428 cubepo = '%s.po' % lang |
433 cubepo = '%s.po' % lang |
429 if not exists(cubepo): |
434 if not exists(cubepo): |
430 shutil.copy(potfile, cubepo) |
435 shutil.copy(potfile, cubepo) |
519 # details. |
524 # details. |
520 # |
525 # |
521 # You should have received a copy of the GNU Lesser General Public License along |
526 # You should have received a copy of the GNU Lesser General Public License along |
522 # with this program. If not, see <http://www.gnu.org/licenses/>. |
527 # with this program. If not, see <http://www.gnu.org/licenses/>. |
523 ''', |
528 ''', |
|
529 |
524 'GPL': '''\ |
530 'GPL': '''\ |
525 # This program is free software: you can redistribute it and/or modify it under |
531 # This program is free software: you can redistribute it and/or modify it under |
526 # the terms of the GNU General Public License as published by the Free Software |
532 # the terms of the GNU General Public License as published by the Free Software |
527 # Foundation, either version 2.1 of the License, or (at your option) any later |
533 # Foundation, either version 2.1 of the License, or (at your option) any later |
528 # version. |
534 # version. |