Exemplo n.º 1
0
 def __call__(self):
     scm.tested_for_scms(('svn', 'gitsvn', 'git'), '.')
     scm.require_package_root_cwd()
     self.check_conditions()
     package_name = scm.get_package_name('.')
     if self.options.domain:
         domain = self.options.domain
     else:
         domain = package_name
     package_root = scm.get_package_root_path('.')
     package_dir = os.path.join(package_root, *package_name.split('.'))
     pot_path = os.path.join(self.locales_dir, '%s.pot' % domain)
     output.part_title('Rebuilding pot file at %s' % pot_path)
     # rebuild
     cmd = ['%s rebuild-pot' % self.i18ndude]
     cmd.append('--pot %s' % pot_path)
     # manual file
     manual_file = os.path.join(self.locales_dir, '%s-manual.pot' % domain)
     if os.path.exists(manual_file):
         print '  merging manual pot file:', manual_file
         cmd.append('--merge %s' % manual_file)
     cmd.append('--create %s %s' % (
             domain,
             package_dir,
             ))
     cmd = ' \\\n'.join(cmd)
     runcmd(cmd)
Exemplo n.º 2
0
 def __call__(self):
     scm.tested_for_scms(('svn', 'gitsvn', 'git'), '.')
     scm.require_package_root_cwd()
     if len(self.args) < 1:
         output.error('Language code is required', exit=1)
     lang = self.args[0]
     # check
     self.check_conditions()
     package_name = scm.get_package_name('.')
     if self.options.domain:
         domain = self.options.domain
     else:
         domain = package_name
     # check pot file
     pot_path = os.path.join(self.locales_dir, '%s.pot' % domain)
     if not os.path.exists(pot_path):
         output.error('Could not find pot file at: %s' % pot_path, exit=1)
     # check language directory
     lang_dir = os.path.join(self.locales_dir, lang, 'LC_MESSAGES')
     if not os.path.isdir(lang_dir):
         runcmd('mkdir -p %s' % lang_dir)
     # touch po file
     po_file = os.path.join(lang_dir, '%s.po' % domain)
     if not os.path.isfile(po_file):
         runcmd('touch %s' % po_file)
     # sync
     output.part_title('Syncing language "%s"' % lang)
     cmd = '%s sync --pot %s %s' % (
         self.i18ndude,
         pot_path,
         po_file,
         )
     runcmd(cmd)
     # remove language
     output.part_title('Removing language code from po file')
     data = open(po_file).read().split('\n')
     file = open(po_file, 'w')
     for row in data:
         if not row.startswith('"Language-Code') and \
                 not row.startswith('"Language-Name'):
             file.write(row)
             file.write('\n')
     file.close()