[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [60860] trunk/blender/release/scripts/ modules/bl_i18n_utils: More complete handling of printf formatting in msgid /msgstr checks.

Bastien Montagne montagne29 at wanadoo.fr
Sat Oct 19 16:28:32 CEST 2013


Revision: 60860
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60860
Author:   mont29
Date:     2013-10-19 14:28:32 +0000 (Sat, 19 Oct 2013)
Log Message:
-----------
More complete handling of printf formatting in msgid/msgstr checks.

(That commit, r60813, should never have been done to 2.69 branch, will revert it there, sorry :/ ).

Revision Links:
--------------
    http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=60813

Modified Paths:
--------------
    trunk/blender/release/scripts/modules/bl_i18n_utils/settings.py
    trunk/blender/release/scripts/modules/bl_i18n_utils/utils.py

Modified: trunk/blender/release/scripts/modules/bl_i18n_utils/settings.py
===================================================================
--- trunk/blender/release/scripts/modules/bl_i18n_utils/settings.py	2013-10-19 14:04:06 UTC (rev 60859)
+++ trunk/blender/release/scripts/modules/bl_i18n_utils/settings.py	2013-10-19 14:28:32 UTC (rev 60860)
@@ -257,6 +257,16 @@
           for it in ("BLF_I18N_MSGID_MULTI_CTXT",))
 )
 
+# Check printf mismatches between msgid and msgstr.
+CHECK_PRINTF_FORMAT = (
+    r"(?!<%)(?:%%)*%"          # Begining, with handling for crazy things like '%%%%%s'
+    r"[-+#0]?"                 # Flags (note: do not add the ' ' (space) flag here, generates too much false positives!)
+    r"(?:\*|[0-9]+)?"          # Width
+    r"(?:\.(?:\*|[0-9]+))?"    # Precision
+    r"(?:[hljztL]|hh|ll)?"     # Length
+    r"[tldiuoxXfFeEgGaAcspn]"  # Specifiers (note we have Blender-specific %t and %l ones too)
+)
+
 # Should po parser warn when finding a first letter not capitalized?
 WARN_MSGID_NOT_CAPITALIZED = True
 

Modified: trunk/blender/release/scripts/modules/bl_i18n_utils/utils.py
===================================================================
--- trunk/blender/release/scripts/modules/bl_i18n_utils/utils.py	2013-10-19 14:04:06 UTC (rev 60859)
+++ trunk/blender/release/scripts/modules/bl_i18n_utils/utils.py	2013-10-19 14:28:32 UTC (rev 60860)
@@ -446,10 +446,10 @@
         """
         ret = []
         default_context = self.settings.DEFAULT_CONTEXT
-        _format = re.compile("%[.0-9]*[tslfd]").findall
+        _format = re.compile(self.settings.CHECK_PRINTF_FORMAT).findall
         done_keys = set()
+        rem = set()
         tmp = {}
-        rem = set()
         for key, msg in self.msgs.items():
             msgctxt, msgid, msgstr = msg.msgctxt, msg.msgid, msg.msgstr
             real_key = (msgctxt or default_context, msgid)
@@ -464,7 +464,7 @@
             done_keys.add(key)
             if '%' in msgid and msgstr and _format(msgid) != _format(msgstr):
                 if not msg.is_fuzzy:
-                    ret.append("Error! msg's format entities are not matched in msgid and msgstr ({} / {})"
+                    ret.append("Error! msg's format entities are not matched in msgid and msgstr ({} / \"{}\")"
                                "".format(real_key, msgstr))
                 if fix:
                     msg.msgstr = ""




More information about the Bf-blender-cvs mailing list