summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorOlivier Dony <odo@openerp.com>2012-09-18 15:51:11 +0200
committerOlivier Dony <odo@openerp.com>2012-09-18 15:51:11 +0200
commit13dfee0de0fdca7edfc0eae157ebcb8904a6a8df (patch)
tree70879fb475ba0303ef7382b97e9cf58da720cf52
parenta3a2ec416b3fb4be2dbf6ed0333b3d1417ddc206 (diff)
[IMP] translations: keep only one method for loading translations
bzr revid: odo@openerp.com-20120918135111-o6ylzs1n36kqkh4c
-rw-r--r--addons/web/controllers/main.py41
1 files changed, 12 insertions, 29 deletions
diff --git a/addons/web/controllers/main.py b/addons/web/controllers/main.py
index 35698d1085d..234d765d5c7 100644
--- a/addons/web/controllers/main.py
+++ b/addons/web/controllers/main.py
@@ -19,6 +19,7 @@ import zlib
from xml.etree import ElementTree
from cStringIO import StringIO
+import babel.messages.pofile
import werkzeug.utils
import werkzeug.wrappers
try:
@@ -492,35 +493,17 @@ def parse_context(context, session):
return common.nonliterals.Context(session, context)
-# PO file parsing - only used to boostrap translations on the login page
-try:
- # Use the faster PO parser from OpenERP server when available
- from openerp.tools.translate import TinyPoFile
- def _local_web_translations(trans_file):
- messages = []
- try:
- with open(trans_file) as t_file:
- po = TinyPoFile(t_file)
- for _, _, _, source, value, comments in po:
- if "openerp-web" in comments:
- messages.append({'id': source, 'string': value})
- except Exception:
- pass
- return messages
-except ImportError:
- # Otherwise fallback to Babel's slightly slower PO parser
- import babel.messages.pofile
- def _local_web_translations(trans_file):
- messages = []
- try:
- with open(trans_file) as t_file:
- po = babel.messages.pofile.read_po(t_file)
- except Exception:
- return
- for x in po:
- if x.id and x.string and "openerp-web" in x.auto_comments:
- messages.append({'id': x.id, 'string': x.string})
- return messages
+def _local_web_translations(trans_file):
+ messages = []
+ try:
+ with open(trans_file) as t_file:
+ po = babel.messages.pofile.read_po(t_file)
+ except Exception:
+ return
+ for x in po:
+ if x.id and x.string and "openerp-web" in x.auto_comments:
+ messages.append({'id': x.id, 'string': x.string})
+ return messages
#----------------------------------------------------------