[IMP] translate: ignore 0-1 letter terms during terms export + catch and log babel...
authorOlivier Dony <odo@openerp.com>
Fri, 23 Nov 2012 23:51:30 +0000 (00:51 +0100)
committerOlivier Dony <odo@openerp.com>
Fri, 23 Nov 2012 23:51:30 +0000 (00:51 +0100)
bzr revid: odo@openerp.com-20121123235130-euhbx6zqs5118472

openerp/tools/translate.py

index f388f06..f373f71 100644 (file)
@@ -23,7 +23,6 @@ import codecs
 import csv
 import fnmatch
 import inspect
-import itertools
 import locale
 import os
 import openerp.pooler as pooler
@@ -618,7 +617,12 @@ def trans_generate(lang, modules, cr):
     _to_translate = []
     def push_translation(module, type, name, id, source, comments=None):
         tuple = (module, source, name, id, type, comments or [])
-        if source and tuple not in _to_translate:
+        # empty and one-letter terms are ignored, they probably are not meant to be
+        # translated, and would be very hard to translate anyway.
+        if not source or len(source.strip()) <= 1:
+            _logger.debug("Ignoring empty or 1-letter source term: %r", tuple)
+            return
+        if tuple not in _to_translate:
             _to_translate.append(tuple)
 
     def encode(s):
@@ -841,6 +845,8 @@ def trans_generate(lang, modules, cr):
                                                                  keywords=extract_keywords):
                     push_translation(module, trans_type, display_path, lineno,
                                      encode(message), comments + extra_comments)
+            except Exception:
+                _logger.exception("Failed to extract terms from %s", fabsolutepath)
             finally:
                 src_file.close()