Few minor fixes to i18n tools (mostly use ordered dicts too for "xgettexted" messages...).

This commit is contained in:
Bastien Montagne 2012-10-14 14:18:30 +00:00
parent 459a2b38e0
commit 7b8dc4be0d
2 changed files with 25 additions and 19 deletions

@ -117,9 +117,9 @@ def check_file(path, rel_path, messages):
def py_xgettext(messages): def py_xgettext(messages):
with open(SRC_POTFILES) as src:
forbidden = set() forbidden = set()
forced = set() forced = set()
with open(SRC_POTFILES) as src:
for l in src: for l in src:
if l[0] == '-': if l[0] == '-':
forbidden.add(l[1:].rstrip('\n')) forbidden.add(l[1:].rstrip('\n'))
@ -133,8 +133,10 @@ def py_xgettext(messages):
continue continue
path = os.path.join(root, fname) path = os.path.join(root, fname)
rel_path = os.path.relpath(path, SOURCE_DIR) rel_path = os.path.relpath(path, SOURCE_DIR)
if rel_path in forbidden | forced: if rel_path in forbidden:
continue continue
elif rel_path in forced:
forced.remove(rel_path)
check_file(path, rel_path, messages) check_file(path, rel_path, messages)
for path in forced: for path in forced:
if os.path.exists(path): if os.path.exists(path):
@ -250,7 +252,7 @@ def main():
print("Running fake py gettext…") print("Running fake py gettext…")
# Not using any more xgettext, simpler to do it ourself! # Not using any more xgettext, simpler to do it ourself!
messages = {} messages = utils.new_messages()
py_xgettext(messages) py_xgettext(messages)
print("Finished, found {} messages.".format(len(messages))) print("Finished, found {} messages.".format(len(messages)))
@ -268,7 +270,7 @@ def main():
# add messages collected automatically from RNA # add messages collected automatically from RNA
print("\tMerging RNA messages from {}".format(FILE_NAME_MESSAGES)) print("\tMerging RNA messages from {}".format(FILE_NAME_MESSAGES))
messages = {} messages = utils.new_messages()
with open(FILE_NAME_MESSAGES, encoding="utf-8") as f: with open(FILE_NAME_MESSAGES, encoding="utf-8") as f:
srcs = [] srcs = []
context = "" context = ""

@ -41,6 +41,10 @@ def is_tooltip(msgid):
return len(msgid) > 30 return len(msgid) > 30
def new_messages():
return getattr(collections, 'OrderedDict', dict)()
def parse_messages(fname): def parse_messages(fname):
""" """
Returns a tupple (messages, states, stats). Returns a tupple (messages, states, stats).
@ -78,7 +82,7 @@ def parse_messages(fname):
msgctxt_lines = [] msgctxt_lines = []
comment_lines = [] comment_lines = []
messages = getattr(collections, 'OrderedDict', dict)() messages = new_messages()
translated_messages = set() translated_messages = set()
fuzzy_messages = set() fuzzy_messages = set()
commented_messages = set() commented_messages = set()
@ -282,7 +286,7 @@ def gen_empty_messages(blender_rev, time_str, year_str):
"""Generate an empty messages & state data (only header if present!).""" """Generate an empty messages & state data (only header if present!)."""
header_key = ("", "") header_key = ("", "")
messages = getattr(collections, 'OrderedDict', dict)() messages = new_messages()
messages[header_key] = { messages[header_key] = {
"msgid_lines": [""], "msgid_lines": [""],
"msgctxt_lines": [], "msgctxt_lines": [],