Commit 9d950436 by Ned Batchelder

Merge pull request #2303 from edx/ned/i18n-tool-fixes

Ned/i18n tool fixes
parents 42933739 1e8a0cb7
......@@ -41,9 +41,6 @@ def main():
create_dir_if_necessary(LOCALE_DIR)
source_msgs_dir = CONFIGURATION.source_messages_dir
generated_files = ['django-partial.po', 'djangojs.po', 'mako.po']
# Prepare makemessages command.
makemessages = "django-admin.py makemessages -l en"
ignores = " ".join('--ignore="{}/*"'.format(d) for d in CONFIGURATION.ignore_dirs)
if ignores:
......@@ -70,10 +67,9 @@ def main():
# Segment the generated files.
segmented_files = segment_pofiles("en")
generated_files.extend(segmented_files)
# Finish each file.
for filename in generated_files:
for filename in segmented_files:
LOG.info('Cleaning %s' % filename)
po = pofile(source_msgs_dir.joinpath(filename))
# replace default headers with edX headers
......
......@@ -42,10 +42,8 @@ def main(file, locale):
for msg in pofile:
converter.convert_msg(msg)
# If any message has a plural, then the file needs plural information.
# Apply declaration for English pluralization rules so that ngettext will
# do something reasonable.
if any(m.msgid_plural for m in pofile):
pofile.metadata['Plural-Forms'] = 'nplurals=2; plural=(n != 1);'
new_file = new_filename(file, locale)
......
......@@ -93,13 +93,13 @@ def segment_pofile(filename, segments):
else:
msg_segments.add(filename)
assert msg_segments
if len(msg_segments) == 1:
# This message belongs in this segment.
segment_file = msg_segments.pop()
segment_po_files[segment_file].append(msg)
else:
# Either it's in more than one segment, or none, so put it back in
# the main file.
# It's in more than one segment, so put it back in the main file.
remaining_po.append(msg)
# Write out the results.
......@@ -113,9 +113,6 @@ def segment_pofile(filename, segments):
pofile.save(out_file)
files_written.add(out_file)
LOG.info(writing_msg.format(file=filename, num=len(remaining_po)))
remaining_po.save(filename)
return files_written
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment