[Bf-translations-svn] SVN commit: /data/svn/bf-translations [431] trunk/po: Now generating POTFILES.in as part of update_branches.py script.

bf-translations at blender.org bf-translations at blender.org
Sat Mar 3 18:21:16 CET 2012


Revision: 431
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-translations&revision=431
Author:   mont29
Date:     2012-03-03 17:21:12 +0000 (Sat, 03 Mar 2012)
Log Message:
-----------
Now generating POTFILES.in as part of update_branches.py script.

Keeping that file in sync was just impossible (was already outdated), now update_potinput.py scans the whole Blender source dir, and generates a list of files for xgettext to parse in /trunk/po/POTFILES.in.

If you want to manually force a file to be parsed by xgettext, add its relative path into /trunk/po/_POTFILES.in. And if you want to forbid a file's parsing, add its path prefixed with '-' in _POTFILES.in.

Modified Paths:
--------------
    trunk/po/POTFILES.in
    trunk/po/tools/settings_template.py
    trunk/po/tools/update_branches.py

Added Paths:
-----------
    trunk/po/_POTFILES.in
    trunk/po/tools/update_potinput.py

Modified: trunk/po/POTFILES.in
===================================================================
--- trunk/po/POTFILES.in	2012-03-03 17:19:28 UTC (rev 430)
+++ trunk/po/POTFILES.in	2012-03-03 17:21:12 UTC (rev 431)
@@ -1,39 +1,28 @@
-source/blender/blenkernel/intern/anim_sys.c
-source/blender/blenkernel/intern/blender.c
-source/blender/blenkernel/intern/packedFile.c
-source/blender/blenkernel/intern/sequencer.c
-source/blender/blenkernel/intern/writeavi.c
-source/blender/blenkernel/intern/writeffmpeg.c
-source/blender/blenkernel/intern/writeframeserver.c
-
+source/blender/python/intern/bpy_rna.c
+source/blender/editors/interface/interface.c
+source/blender/editors/interface/interface_regions.c
 source/blender/editors/interface/interface_panel.c
 source/blender/editors/interface/interface_utils.c
 source/blender/editors/interface/interface_templates.c
 source/blender/editors/interface/interface_layout.c
-source/blender/editors/interface/interface_regions.c
-
-source/blender/editors/space_buttons/buttons_header.c
-
+source/blender/editors/gpencil/gpencil_buttons.c
 source/blender/editors/space_file/file_panels.c
 source/blender/editors/space_file/file_draw.c
-
+source/blender/editors/space_buttons/buttons_header.c
 source/blender/editors/space_view3d/view3d_header.c
 source/blender/editors/space_view3d/view3d_toolbar.c
-
+source/blender/editors/space_view3d/view3d_buttons.c
 source/blender/editors/space_info/space_info.c
-
 source/blender/editors/space_nla/nla_buttons.c
-
 source/blender/editors/transform/transform_orientations.c
-
 source/blender/editors/space_graph/graph_buttons.c
-
 source/blender/editors/screen/area.c
-
-source/blender/editors/space_node/node_header.c
-
+source/blender/editors/space_node/node_templates.c
 source/blender/editors/armature/poselib.c
-
 source/blender/windowmanager/intern/wm_window.c
 source/blender/windowmanager/intern/wm_operators.c
 source/blender/windowmanager/intern/wm_files.c
+source/blender/nodes/texture/node_texture_tree.c
+source/blender/nodes/composite/node_composite_tree.c
+source/blender/nodes/shader/node_shader_tree.c
+source/blender/render/intern/source/external_engine.c

Added: trunk/po/_POTFILES.in
===================================================================
--- trunk/po/_POTFILES.in	                        (rev 0)
+++ trunk/po/_POTFILES.in	2012-03-03 17:21:12 UTC (rev 431)
@@ -0,0 +1,4 @@
+# File in which you may specify files to parse with gettext.
+# NOTE: You should never need this... Here "just in case"!
+# Use - prefix to forbid xgettext-parsing of this file.
+-source/blender/blenfont/BLF_translation.h

Modified: trunk/po/tools/settings_template.py
===================================================================
--- trunk/po/tools/settings_template.py	2012-03-03 17:19:28 UTC (rev 430)
+++ trunk/po/tools/settings_template.py	2012-03-03 17:21:12 UTC (rev 431)
@@ -169,7 +169,15 @@
 # The file storing Blender-generated messages.
 FILE_NAME_MESSAGES = os.path.join(TRUNK_PO_DIR, "messages.txt")
 
-# The file storing which files should be processed by xgettext.
+# The Blender source path to check for i18n macros.
+POTFILES_SOURCE_DIR = os.path.join(SOURCE_DIR, "source")
+
+# The "source" file storing which files should be processed by xgettext,
+# used to create FILE_NAME_POTFILES
+FILE_NAME_SRC_POTFILES = os.path.join(TRUNK_PO_DIR, "_POTFILES.in")
+
+# The final (generated) file storing which files
+# should be processed by xgettext.
 FILE_NAME_POTFILES = os.path.join(TRUNK_PO_DIR, "POTFILES.in")
 
 # The template messages file.

Modified: trunk/po/tools/update_branches.py
===================================================================
--- trunk/po/tools/update_branches.py	2012-03-03 17:19:28 UTC (rev 430)
+++ trunk/po/tools/update_branches.py	2012-03-03 17:21:12 UTC (rev 431)
@@ -60,6 +60,12 @@
     if t:
         ret = t
 
+    # Regenerate POTFILES.in.
+    cmd = (PY3, "./update_potinput.py")
+    t = subprocess.call(cmd)
+    if t:
+        ret = t
+
     # Generate a temp pot file.
     dummy, potfile = tempfile.mkstemp(suffix=".pot",
                                       prefix="blender_pot_")

Added: trunk/po/tools/update_potinput.py
===================================================================
--- trunk/po/tools/update_potinput.py	                        (rev 0)
+++ trunk/po/tools/update_potinput.py	2012-03-03 17:21:12 UTC (rev 431)
@@ -0,0 +1,86 @@
+#!/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>
+
+# Create or update FILE_NAME_POTFILES file by scanning sources to find
+# usages of IFACE_, TIP_ or N_ macros.
+
+
+import os
+import sys
+import subprocess
+
+import settings
+
+
+SOURCE_DIR = settings.SOURCE_DIR
+POTFILES_DIR = settings.POTFILES_SOURCE_DIR
+SRC_POTFILES = settings.FILE_NAME_SRC_POTFILES
+POTFILES = settings.FILE_NAME_POTFILES
+MACROS = settings.GETTEXT_KEYWORDS
+
+
+def check_file(fname):
+    """Search for i18n macros in a (text-opened) file."""
+    with open(fname) as f:
+        for l in f:
+            for macro in MACROS:
+                if macro + '(' in l:
+                    return True
+    return False
+
+
+def main():
+    import argparse
+    parser = argparse.ArgumentParser(description="Create or update {} file by "
+                                                 "scanning sources to find "
+                                                 "usages of I18N macros."
+                                                 "".format(POTFILES))
+    args = parser.parse_args()
+
+
+    ret = 0
+
+    with open(POTFILES, "w") as f, open(SRC_POTFILES) as src:
+        forbidden = set()
+        for l in src:
+            if l[0] == '-':
+                forbidden.add(l[1:].rstrip('\n'))
+            elif l[0] != '#':
+                f.write(l + '\n')
+        for root, dirs, files in os.walk(POTFILES_DIR):
+            if "/.svn" in root:
+                continue
+            for fname in files:
+                path = os.path.join(root, fname)
+                try:
+                    if check_file(path):
+                        path = os.path.relpath(path, SOURCE_DIR)
+                        if path not in forbidden:
+                            f.write(path + '\n')
+                except:
+                    pass
+
+    return ret
+
+if __name__ == "__main__":
+    print("\n\n *** Running {} *** \n".format(__file__))
+    sys.exit(main())



More information about the Bf-translations-svn mailing list