if not self.input_file:
if self.locale:
- po_files.append(os.path.join(self.directory, self.locale,
- 'LC_MESSAGES',
- self.domain + '.po'))
+ po_files.append((self.locale,
+ os.path.join(self.directory, self.locale,
+ 'LC_MESSAGES',
+ self.domain + '.po')))
mo_files.append(os.path.join(self.directory, self.locale,
'LC_MESSAGES',
self.domain + '.mo'))
po_file = os.path.join(self.directory, locale,
'LC_MESSAGES', self.domain + '.po')
if os.path.exists(po_file):
- po_files.append(po_file)
+ po_files.append((locale, po_file))
mo_files.append(os.path.join(self.directory, locale,
'LC_MESSAGES',
self.domain + '.mo'))
else:
- po_files.append(self.input_file)
+ po_files.append((self.locale, self.input_file))
if self.output_file:
mo_files.append(self.output_file)
else:
if not po_files:
raise DistutilsOptionError('no message catalogs found')
- for idx, po_file in enumerate(po_files):
+ for idx, (locale, po_file) in enumerate(po_files):
mo_file = mo_files[idx]
infile = open(po_file, 'r')
try:
- catalog = read_po(infile)
+ catalog = read_po(infile, locale)
finally:
infile.close()
parser.error('you must specify either the input file or the '
'base directory')
if options.locale:
- po_files.append(os.path.join(options.directory, options.locale,
- 'LC_MESSAGES',
- options.domain + '.po'))
+ po_files.append((options.locale,
+ os.path.join(options.directory,
+ options.locale, 'LC_MESSAGES',
+ options.domain + '.po')))
mo_files.append(os.path.join(options.directory, options.locale,
'LC_MESSAGES',
options.domain + '.mo'))
po_file = os.path.join(options.directory, locale,
'LC_MESSAGES', options.domain + '.po')
if os.path.exists(po_file):
- po_files.append(po_file)
+ po_files.append((locale, po_file))
mo_files.append(os.path.join(options.directory, locale,
'LC_MESSAGES',
options.domain + '.mo'))
else:
- po_files.append(options.input_file)
+ po_files.append((options.locale, options.input_file))
if options.output_file:
mo_files.append(options.output_file)
else:
if not po_files:
parser.error('no message catalogs found')
- for idx, po_file in enumerate(po_files):
+ for idx, (locale, po_file) in enumerate(po_files):
mo_file = mo_files[idx]
infile = open(po_file, 'r')
try:
- catalog = read_po(infile)
+ catalog = read_po(infile, locale)
finally:
infile.close()
assert os.path.isfile(mo_file)
self.assertEqual("""\
compiling catalog %r to %r
+""" % (po_file, mo_file), sys.stderr.getvalue())
+ finally:
+ if os.path.isfile(mo_file):
+ os.unlink(mo_file)
+
+ def test_compile_catalog_with_more_than_2_plural_forms(self):
+ po_file = os.path.join(self.datadir, 'project', 'i18n', 'ru_RU',
+ 'LC_MESSAGES', 'messages.po')
+ mo_file = po_file.replace('.po', '.mo')
+ try:
+ self.cli.run(sys.argv + ['compile',
+ '--locale', 'ru_RU', '--use-fuzzy',
+ '-d', os.path.join(self.datadir, 'project', 'i18n')])
+ assert os.path.isfile(mo_file)
+ self.assertEqual("""\
+compiling catalog %r to %r
""" % (po_file, mo_file), sys.stderr.getvalue())
finally:
if os.path.isfile(mo_file):