[IMP] translations: keep only one method for loading translations
bzr revid: odo@openerp.com-20120918135111-o6ylzs1n36kqkh4c
This commit is contained in:
parent
a3a2ec416b
commit
13dfee0de0
|
@ -19,6 +19,7 @@ import zlib
|
||||||
from xml.etree import ElementTree
|
from xml.etree import ElementTree
|
||||||
from cStringIO import StringIO
|
from cStringIO import StringIO
|
||||||
|
|
||||||
|
import babel.messages.pofile
|
||||||
import werkzeug.utils
|
import werkzeug.utils
|
||||||
import werkzeug.wrappers
|
import werkzeug.wrappers
|
||||||
try:
|
try:
|
||||||
|
@ -492,24 +493,6 @@ def parse_context(context, session):
|
||||||
return common.nonliterals.Context(session, context)
|
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):
|
def _local_web_translations(trans_file):
|
||||||
messages = []
|
messages = []
|
||||||
try:
|
try:
|
||||||
|
|
Loading…
Reference in New Issue