summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristophe Simonis <christophe@tinyerp.com>2008-07-15 10:40:23 +0200
committerChristophe Simonis <christophe@tinyerp.com>2008-07-15 10:40:23 +0200
commit4e80903f940f8d7ff109b241504ddbb6c4bcfd2a (patch)
tree5ad69bed7cd2f1396d754512915434e72ad6a691
parentf4698375636d5d73e1e8687e6d387fec20bc9b2c (diff)
now _() works !
but bzr... bzr revid: christophe@tinyerp.com-20080715084023-tzhwid7be6r8067u
-rw-r--r--bin/tools/translate.py20
1 files changed, 12 insertions, 8 deletions
diff --git a/bin/tools/translate.py b/bin/tools/translate.py
index fa230e7241e..e38c0f203b1 100644
--- a/bin/tools/translate.py
+++ b/bin/tools/translate.py
@@ -34,7 +34,7 @@ import osv, tools, pooler
import ir
import netsvc
from tools.misc import UpdateableStr
-
+import inspect
class UNIX_LINE_TERMINATOR(csv.excel):
lineterminator = '\n'
@@ -55,13 +55,17 @@ def translate(cr, name, source_type, lang, source=None):
res = res_trans and res_trans[0] or False
return res
-def translate_code(cr, source, context):
- lang = context.get('lang', False)
- if lang:
- return translate(cr, None, 'code', lang, source) or source
- else:
- return source
-_ = lambda source: translate_code(cr, source, context)
+class GettextAlias(object):
+ def __call__(self, source):
+ frame = inspect.stack()[1][0]
+ cr = frame.f_locals['cr']
+ context = frame.f_locals.get('context', {})
+ lang = context.get('lang', False)
+ if not lang:
+ return source
+ return translate(cr, None, 'code', lang, source) or source
+
+_ = GettextAlias()
# Methods to export the translation file