[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [55407] trunk/blender/release/scripts/ modules/bl_i18n_utils: More i18n tools cleanup.
Bastien Montagne
montagne29 at wanadoo.fr
Tue Mar 19 11:11:41 CET 2013
Revision: 55407
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=55407
Author: mont29
Date: 2013-03-19 10:11:41 +0000 (Tue, 19 Mar 2013)
Log Message:
-----------
More i18n tools cleanup. Also do not import nl in trunk currently (void translation)!
Modified Paths:
--------------
trunk/blender/release/scripts/modules/bl_i18n_utils/settings.py
Removed Paths:
-------------
trunk/blender/release/scripts/modules/bl_i18n_utils/check_po.py
trunk/blender/release/scripts/modules/bl_i18n_utils/clean_po.py
trunk/blender/release/scripts/modules/bl_i18n_utils/import_po_from_branches.py
trunk/blender/release/scripts/modules/bl_i18n_utils/update_branches.py
trunk/blender/release/scripts/modules/bl_i18n_utils/update_mo.py
trunk/blender/release/scripts/modules/bl_i18n_utils/update_msg.py
trunk/blender/release/scripts/modules/bl_i18n_utils/update_po.py
trunk/blender/release/scripts/modules/bl_i18n_utils/update_pot.py
trunk/blender/release/scripts/modules/bl_i18n_utils/update_trunk.py
Deleted: trunk/blender/release/scripts/modules/bl_i18n_utils/check_po.py
===================================================================
--- trunk/blender/release/scripts/modules/bl_i18n_utils/check_po.py 2013-03-19 10:07:23 UTC (rev 55406)
+++ trunk/blender/release/scripts/modules/bl_i18n_utils/check_po.py 2013-03-19 10:11:41 UTC (rev 55407)
@@ -1,178 +0,0 @@
-#!/usr/bin/python3
-
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-# <pep8 compliant>
-
-# Check po’s in branches (or in trunk) for missing/unneeded messages.
-
-import os
-import sys
-from codecs import open
-
-try:
- import settings
- import utils
-except:
- from . import (settings, utils)
-
-TRUNK_PO_DIR = settings.TRUNK_PO_DIR
-BRANCHES_DIR = settings.BRANCHES_DIR
-
-FILE_NAME_POT = settings.FILE_NAME_POT
-
-
-def print_diff(ref_msgs, msgs):
- # Remove comments from messages list!
- messages = set(msgs.msgs.keys()) - msgs.comm_msgs
- unneeded = (messages - ref_msgs.msgs.keys())
- for msgkey in unneeded:
- print('\tUnneeded message context/id "{}"'.format(msgkey))
-
- missing = (ref_msgs.msgs.keys() - messages)
- for msgkey in missing:
- print('\tMissing message context/id "{}"'.format(msgkey))
-
- for msgid in msgs.comm_msgs:
- print('\tCommented message context/id "{}"'.format(msgkey))
-
- print("\t{} unneeded messages, {} missing messages, {} commented messages."
- "".format(len(unneeded), len(missing), len(msgs.comm_msgs)))
- return 0
-
-
-#def process_po(ref_messages, po, glob_stats, do_stats, do_messages):
-def process_po(ref_messages, po, do_stats, do_messages):
- print("Checking {}...".format(po))
- ret = 0
-
- messages = utils.I18nMessages(kind='PO', src=po)
- if do_messages:
- t = print_diff(ref_messages, messages)
- if t:
- ret = t
- if do_stats:
- print("\tStats:")
- t = messages.print_stats(prefix=" ")
- if t:
- ret = t
- if messages.parsing_errors:
- print("\tERROR! This .po is broken!")
- ret = 1
- return ret
-
-
-# XXX Quick update for new I18Nfoo objects, need rework!
-def main():
- import argparse
- parser = argparse.ArgumentParser(description="Check po’s in branches " \
- "(or in trunk) for missing" \
- "/unneeded messages.")
- parser.add_argument('-s', '--stats', action="store_true",
- help="Print po’s stats.")
- parser.add_argument('-m', '--messages', action="store_true",
- help="Print po’s missing/unneeded/commented messages.")
- parser.add_argument('-t', '--trunk', action="store_true",
- help="Check po’s in /trunk/po rather than /branches.")
- parser.add_argument('-p', '--pot',
- help="Specify the .pot file used as reference.")
- parser.add_argument('langs', metavar='ISO_code', nargs='*',
- help="Restrict processed languages to those.")
- args = parser.parse_args()
-
- if args.pot:
- global FILE_NAME_POT
- FILE_NAME_POT = args.pot
- #glob_stats = {"nbr" : 0.0,
- #"lvl" : 0.0,
- #"lvl_ttips" : 0.0,
- #"lvl_trans_ttips" : 0.0,
- #"lvl_ttips_in_trans": 0.0,
- #"lvl_comm" : 0.0,
- #"nbr_signs" : 0,
- #"nbr_trans_signs" : 0,
- #"contexts" : set()}
- ret = 0
-
- pot_messages = None
- if args.messages:
- pot_messages = utils.I18nMessages(kind='PO', src=FILE_NAME_POT)
- #glob_stats["nbr_signs"] = pot_stats["nbr_signs"]
-
- if args.langs:
- for lang in args.langs:
- if args.trunk:
- po = os.path.join(TRUNK_PO_DIR, ".".join((lang, "po")))
- else:
- po = os.path.join(BRANCHES_DIR, lang, ".".join((lang, "po")))
- if os.path.exists(po):
- #t = process_po(pot_messages, po, glob_stats, args.stats, args.messages)
- t = process_po(pot_messages, po, args.stats, args.messages)
- if t:
- ret = t
- elif args.trunk:
- for po in os.listdir(TRUNK_PO_DIR):
- if po.endswith(".po"):
- po = os.path.join(TRUNK_PO_DIR, po)
- #t = process_po(pot_messages, po, glob_stats, args.stats, args.messages)
- t = process_po(pot_messages, po, args.stats, args.messages)
- if t:
- ret = t
- else:
- for lang in os.listdir(BRANCHES_DIR):
- for po in os.listdir(os.path.join(BRANCHES_DIR, lang)):
- if po.endswith(".po"):
- po = os.path.join(BRANCHES_DIR, lang, po)
- #t = process_po(pot_messages, po, glob_stats, args.stats, args.messages)
- t = process_po(pot_messages, po, args.stats, args.messages)
- if t:
- ret = t
-
- #if args.stats and glob_stats["nbr"] != 0.0:
- #nbr_contexts = len(glob_stats["contexts"] - {""})
- #if nbr_contexts != 1:
- #if nbr_contexts == 0:
- #nbr_contexts = "No"
- #_ctx_txt = "s are"
- #else:
- #_ctx_txt = " is"
- #print("\nAverage stats for all {:.0f} processed files:\n"
- #" {:>6.1%} done!\n"
- #" {:>6.1%} of messages are tooltips.\n"
- #" {:>6.1%} of tooltips are translated.\n"
- #" {:>6.1%} of translated messages are tooltips.\n"
- #" {:>6.1%} of messages are commented.\n"
- #" The org msgids are currently made of {} signs.\n"
- #" All processed translations are currently made of {} signs.\n"
- #" {} specific context{} present:\n {}\n"
- #"".format(glob_stats["nbr"], glob_stats["lvl"] / glob_stats["nbr"],
- #glob_stats["lvl_ttips"] / glob_stats["nbr"],
- #glob_stats["lvl_trans_ttips"] / glob_stats["nbr"],
- #glob_stats["lvl_ttips_in_trans"] / glob_stats["nbr"],
- #glob_stats["lvl_comm"] / glob_stats["nbr"], glob_stats["nbr_signs"],
- #glob_stats["nbr_trans_signs"], nbr_contexts, _ctx_txt,
- #"\n ".join(glob_stats["contexts"]-{""})))
-
- return ret
-
-
-if __name__ == "__main__":
- print("\n\n *** Running {} *** \n".format(__file__))
- print(" *** WARNING! Number of tooltips is only an estimation! ***\n")
- sys.exit(main())
Deleted: trunk/blender/release/scripts/modules/bl_i18n_utils/clean_po.py
===================================================================
--- trunk/blender/release/scripts/modules/bl_i18n_utils/clean_po.py 2013-03-19 10:07:23 UTC (rev 55406)
+++ trunk/blender/release/scripts/modules/bl_i18n_utils/clean_po.py 2013-03-19 10:11:41 UTC (rev 55407)
@@ -1,96 +0,0 @@
-#!/usr/bin/python3
-
-# ***** BEGIN GPL LICENSE BLOCK *****
-#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
-#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
-#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ***** END GPL LICENSE BLOCK *****
-
-# <pep8 compliant>
-
-# Clean (i.e. remove commented messages) po’s in branches or trunk.
-
-import os
-import sys
-import collections
-
-try:
- import settings
- import utils
-except:
- from . import (settings, utils)
-
-
-TRUNK_PO_DIR = settings.TRUNK_PO_DIR
-BRANCHES_DIR = settings.BRANCHES_DIR
-
-
-def do_clean(po, strict):
- print("Cleaning {}...".format(po))
- msgs = utils.I18nMessages(kind='PO', src=po)
-
- if strict and msgs.parsing_errors:
- print("ERROR! This .po file is broken!")
- return 1
-
- nbr_rem = len(msgs.comm_msgs)
- for msgkey in msgs.comm_msgs:
- del msgs.msgs[msgkey]
- msgs.write(kind='PO', dest=po)
- print("Removed {} commented messages.".format(nbr_rem))
- return 0
-
-
-def main():
- import argparse
- parser = argparse.ArgumentParser(description="Clean po’s in branches or trunk (i.e. remove all commented "
- "messages).")
- parser.add_argument('-t', '--trunk', action="store_true", help="Clean po’s in trunk rather than branches.")
- parser.add_argument('-s', '--strict', action="store_true", help="Raise an error if a po is broken.")
- parser.add_argument('langs', metavar='ISO_code', nargs='*', help="Restrict processed languages to those.")
- args = parser.parse_args()
-
- ret = 0
-
- if args.langs:
- for lang in args.langs:
- if args.trunk:
- po = os.path.join(TRUNK_PO_DIR, ".".join((lang, "po")))
- else:
- po = os.path.join(BRANCHES_DIR, lang, ".".join((lang, "po")))
- if os.path.exists(po):
- t = do_clean(po, args.strict)
- if t:
- ret = t
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-blender-cvs
mailing list