more i18n commands fixes : 3.5
authorAurélien Campéas
Tue, 08 Sep 2009 14:13:36 +0200
branch3.5
changeset 3118 9e7a155bc4e5
parent 3117 32686ae66c75
child 3119 819aea456251
child 3122 0e49d2679c5c
more i18n commands fixes : * win32 compatible commands * generate .mo even when no priori .mo exists
common/i18n.py
cwconfig.py
devtools/devctl.py
--- a/common/i18n.py	Mon Sep 07 17:46:28 2009 +0200
+++ b/common/i18n.py	Tue Sep 08 14:13:36 2009 +0200
@@ -75,15 +75,15 @@
         mergedpo = join(destdir, '%s_merged.po' % lang)
         try:
             # merge instance/cubes messages catalogs with the stdlib's one
-            execute('msgcat --use-first --sort-output --strict -o %s %s'
+            execute('msgcat --use-first --sort-output --strict -o "%s" %s'
                     % (mergedpo, ' '.join('"%s"' % f for f in pofiles)))
-            # make sure the .mo file is writeable and compile with *msgfmt*
+            # make sure the .mo file is writeable and compiles with *msgfmt*
             applmo = join(destdir, lang, 'LC_MESSAGES', 'cubicweb.mo')
             try:
                 ensure_fs_mode(applmo)
             except OSError:
                 pass # suppose not exists
-            execute('msgfmt %s -o %s' % (mergedpo, applmo))
+            execute('msgfmt "%s" -o "%s"' % (mergedpo, applmo))
         except Exception, ex:
             errors.append('while handling language %s: %s' % (lang, ex))
         try:
--- a/cwconfig.py	Mon Sep 07 17:46:28 2009 +0200
+++ b/cwconfig.py	Tue Sep 08 14:13:36 2009 +0200
@@ -795,8 +795,8 @@
         from glob import glob
         yield 'en' # ensure 'en' is yielded even if no .mo found
         for path in glob(join(self.apphome, 'i18n',
-                              '*', 'LC_MESSAGES', 'cubicweb.mo')):
-            lang = path.split(os.sep)[-3]
+                              '*', 'LC_MESSAGES')):
+            lang = path.split(os.sep)[-2]
             if lang != 'en':
                 yield lang
 
--- a/devtools/devctl.py	Mon Sep 07 17:46:28 2009 +0200
+++ b/devtools/devctl.py	Tue Sep 08 14:13:36 2009 +0200
@@ -10,7 +10,7 @@
 
 import sys
 from datetime import datetime
-from os import mkdir, chdir
+from os import mkdir, chdir, getcwd
 from os.path import join, exists, abspath, basename, normpath, split, isdir
 from warnings import warn
 
@@ -260,7 +260,6 @@
         from logilab.common.shellutils import globfind, find, rm
         from cubicweb.common.i18n import extract_from_tal, execute
         tempdir = tempfile.mkdtemp()
-        assert exists(tempdir)
         potfiles = [join(I18NDIR, 'static-messages.pot')]
         print '-> extract schema messages.'
         schemapot = join(tempdir, 'schema.pot')
@@ -297,10 +296,9 @@
         toedit = []
         for lang in LANGS:
             target = '%s.po' % lang
-            execute('msgmerge -N --sort-output -o %snew %s %s' % (target, cubicwebpot, target))
+            execute('msgmerge -N --sort-output -o "%snew" "%s" "%s"' % (target, target, cubicwebpot))
             ensure_fs_mode(target)
             shutil.move('%snew' % target, target)
-            assert exists(target)
             toedit.append(abspath(target))
         # cleanup
         rm(tempdir)
@@ -392,7 +390,7 @@
     cubefiles = find('.', '.py', blacklist=STD_BLACKLIST+('test',))
     cubefiles.append(tali18nfile)
     execute('xgettext --no-location --omit-header -k_ -o %s %s'
-            % (tmppotfile, ' '.join(cubefiles)))
+            % (tmppotfile, ' '.join('"%s"' % f for f in cubefiles)))
     if exists(tmppotfile): # doesn't exists of no translation string found
         potfiles.append(tmppotfile)
     potfile = join(tempdir, 'cube.pot')
@@ -407,7 +405,7 @@
         if not exists(cubepo):
             shutil.copy(potfile, cubepo)
         else:
-            execute('msgmerge -N -s -o %snew %s %s' % (cubepo, potfile, cubepo))
+            execute('msgmerge -N -s -o %snew %s %s' % (cubepo, cubepo, potfile))
             ensure_fs_mode(cubepo)
             shutil.move('%snew' % cubepo, cubepo)
         toedit.append(abspath(cubepo))