24 # *ctl module should limit the number of import to be imported as quickly as |
24 # *ctl module should limit the number of import to be imported as quickly as |
25 # possible (for cubicweb-ctl reactivity, necessary for instance for usable bash |
25 # possible (for cubicweb-ctl reactivity, necessary for instance for usable bash |
26 # completion). So import locally in command helpers. |
26 # completion). So import locally in command helpers. |
27 import sys |
27 import sys |
28 from datetime import datetime |
28 from datetime import datetime |
29 from os import mkdir, chdir, listdir, path as osp |
29 from os import mkdir, chdir, path as osp |
30 from warnings import warn |
30 from warnings import warn |
31 |
31 |
32 from logilab.common import STD_BLACKLIST |
32 from logilab.common import STD_BLACKLIST |
33 |
33 |
34 from cubicweb.__pkginfo__ import version as cubicwebversion |
34 from cubicweb.__pkginfo__ import version as cubicwebversion |
35 from cubicweb import CW_SOFTWARE_ROOT as BASEDIR, BadCommandUsage |
35 from cubicweb import CW_SOFTWARE_ROOT as BASEDIR, BadCommandUsage |
36 from cubicweb.cwctl import CWCTL |
36 from cubicweb.cwctl import CWCTL |
|
37 from cubicweb.cwconfig import CubicWebNoAppConfiguration |
37 from cubicweb.toolsutils import (SKEL_EXCLUDE, Command, copy_skeleton, |
38 from cubicweb.toolsutils import (SKEL_EXCLUDE, Command, copy_skeleton, |
38 underline_title) |
39 underline_title) |
39 from cubicweb.web.webconfig import WebConfiguration |
40 from cubicweb.web.webconfig import WebConfiguration |
40 from cubicweb.server.serverconfig import ServerConfiguration |
41 from cubicweb.server.serverconfig import ServerConfiguration |
41 |
42 |
261 "Generated-By: cubicweb-devtools\n" |
266 "Generated-By: cubicweb-devtools\n" |
262 "Plural-Forms: nplurals=2; plural=(n > 1);\n" |
267 "Plural-Forms: nplurals=2; plural=(n > 1);\n" |
263 |
268 |
264 ''' % cubicwebversion |
269 ''' % cubicwebversion |
265 |
270 |
266 def cw_languages(): |
|
267 for fname in listdir(osp.join(WebConfiguration.i18n_lib_dir())): |
|
268 if fname.endswith('.po'): |
|
269 yield osp.splitext(fname)[0] |
|
270 |
|
271 |
271 |
272 class UpdateCubicWebCatalogCommand(Command): |
272 class UpdateCubicWebCatalogCommand(Command): |
273 """Update i18n catalogs for cubicweb library. |
273 """Update i18n catalogs for cubicweb library. |
274 |
274 |
275 It will regenerate cubicweb/i18n/xx.po files. You'll have then to edit those |
275 It will regenerate cubicweb/i18n/xx.po files. You'll have then to edit those |
327 execute('msgcat -o %s %s' |
327 execute('msgcat -o %s %s' |
328 % (cubicwebpot, ' '.join('"%s"' % f for f in potfiles))) |
328 % (cubicwebpot, ' '.join('"%s"' % f for f in potfiles))) |
329 print '-> merging main pot file with existing translations.' |
329 print '-> merging main pot file with existing translations.' |
330 chdir(cwi18ndir) |
330 chdir(cwi18ndir) |
331 toedit = [] |
331 toedit = [] |
332 for lang in cw_languages(): |
332 for lang in CubicWebNoAppConfiguration.cw_languages(): |
333 target = '%s.po' % lang |
333 target = '%s.po' % lang |
334 execute('msgmerge -N --sort-output -o "%snew" "%s" "%s"' |
334 execute('msgmerge -N --sort-output -o "%snew" "%s" "%s"' |
335 % (target, target, cubicwebpot)) |
335 % (target, target, cubicwebpot)) |
336 ensure_fs_mode(target) |
336 ensure_fs_mode(target) |
337 shutil.move('%snew' % target, target) |
337 shutil.move('%snew' % target, target) |
442 rm(tempdir) |
442 rm(tempdir) |
443 return () |
443 return () |
444 print '-> merging main pot file with existing translations:' |
444 print '-> merging main pot file with existing translations:' |
445 chdir('i18n') |
445 chdir('i18n') |
446 toedit = [] |
446 toedit = [] |
447 for lang in cw_languages(): |
447 for lang in CubicWebNoAppConfiguration.cw_languages(): |
448 print '-> language', lang |
448 print '-> language', lang |
449 cubepo = '%s.po' % lang |
449 cubepo = '%s.po' % lang |
450 if not osp.exists(cubepo): |
450 if not osp.exists(cubepo): |
451 shutil.copy(potfile, cubepo) |
451 shutil.copy(potfile, cubepo) |
452 else: |
452 else: |