[Bf-translations-svn] SVN commit: /data/svn/bf-translations [169] trunk/po/tools/merge_po.py: Fix to merge_po.py ( by default it was always replacing dest translations by merged ones, now it by default keeps dest translations, unless -r option is used.
bf-translations at blender.org
bf-translations at blender.org
Tue Nov 8 20:45:59 CET 2011
Revision: 169
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-translations&revision=169
Author: mont29
Date: 2011-11-08 19:45:58 +0000 (Tue, 08 Nov 2011)
Log Message:
-----------
Fix to merge_po.py (by default it was always replacing dest translations by merged ones, now it by default keeps dest translations, unless -r option is used.
Modified Paths:
--------------
trunk/po/tools/merge_po.py
Modified: trunk/po/tools/merge_po.py
===================================================================
--- trunk/po/tools/merge_po.py 2011-11-08 19:24:04 UTC (rev 168)
+++ trunk/po/tools/merge_po.py 2011-11-08 19:45:58 UTC (rev 169)
@@ -49,6 +49,8 @@
"from sources.")
parser.add_argument('-s', '--stats', action="store_true",
help="Show statistics info.")
+ parser.add_argument('-r', '--replace', action="store_true",
+ help="Replace existing messages of same \"level\" already in dest po.")
parser.add_argument('dst', metavar='dst.po',
help="The dest po into which merge the others.")
parser.add_argument('src', metavar='src.po', nargs='+',
@@ -86,7 +88,7 @@
if msgid in (done_msgids | dst_states["comm_msg"] | states["comm_msg"]):
continue
is_ttip = utils.is_tooltip(msgid)
- # New messages does not yet exists.
+ # New messages does not yet exists in dest.
if msgid not in dst_messages:
dst_messages[msgid] = messages[msgid]
if msgid in states["fuzzy_msg"]:
@@ -107,8 +109,10 @@
elif msgid not in (states["trans_msg"] | states["fuzzy_msg"]):
continue
# From now on, the new message is either translated or fuzzy!
- # The new message is translated.
- elif msgid in states["trans_msg"]:
+ # The new message is translated, and either replace is enabled,
+ # or the org message is fuzzy.
+ elif msgid in states["trans_msg"] and \
+ (args.replace or msgid not in dst_states["trans_msg"]):
dst_messages[msgid]["msgstr_lines"] = messages[msgid]["msgstr_lines"]
done_msgids.add(msgid)
done_fuzzy_msgids.discard(msgid)
@@ -121,8 +125,9 @@
if is_ttip:
dst_stats["trans_ttips"] += 1
nbr_merged += 1
- # The new message is fuzzy, org one is fuzzy too, and this msgid has not yet been merged.
- elif msgid not in (dst_states["trans_msg"] | done_fuzzy_msgids):
+ # The new message is fuzzy, org one is fuzzy too,
+ # replace is enabled, and this msgid has not yet been merged.
+ elif args.replace and msgid not in (dst_states["trans_msg"] | done_fuzzy_msgids):
dst_messages[msgid]["msgstr_lines"] = messages[msgid]["msgstr_lines"]
done_fuzzy_msgids.add(msgid)
dst_states["fuzzy_msg"].add(msgid)
More information about the Bf-translations-svn
mailing list