[imp] used the user language
[odoo/odoo.git] / addons / base / controllers / main.py
index 83a1a94..d4d4205 100644 (file)
@@ -159,18 +159,23 @@ class WebClient(openerpweb.Controller):
         return r
     
     @openerpweb.jsonrequest
-    def translations(self, addon_name, lang):
-        f_name = os.path.join(openerpweb.path_addons, addon_name, "po", lang + ".po")
-        with open(f_name) as t_file:
-            po = read_po(t_file)
-        
-        transl = {"messages":[]}
-        
-        for x in po:
-            if x.id:
-                transl["messages"].append({'id': x.id, 'string': x.string})
-
-        return transl
+    def translations(self, req, mods, lang):
+        transs = {}
+        for addon_name in mods:
+            transl = {"messages":[]}
+            transs[addon_name] = transl
+            f_name = os.path.join(openerpweb.path_addons, addon_name, "po", lang + ".po")
+            if not os.path.exists(f_name):
+                continue
+            try:
+                with open(f_name) as t_file:
+                    po = read_po(t_file)
+            except:
+                continue
+            for x in po:
+                if x.id:
+                    transl["messages"].append({'id': x.id, 'string': x.string})
+        return {"modules": transs}
     
 
 class Database(openerpweb.Controller):
@@ -267,10 +272,12 @@ class Session(openerpweb.Controller):
     @openerpweb.jsonrequest
     def login(self, req, db, login, password):
         req.session.login(db, login, password)
+        ctx = req.session.get_context()
 
         return {
             "session_id": req.session_id,
             "uid": req.session._uid,
+            "context": ctx
         }
 
     @openerpweb.jsonrequest
@@ -788,8 +795,8 @@ class View(openerpweb.Controller):
         """ Parses an arbitrary string containing a domain, transforms it
         to either a literal domain or a :class:`openerpweb.nonliterals.Domain`
 
-        :param domain: the domain to parse, if the domain is not a string it is assumed to
-        be a literal domain and is returned as-is
+        :param domain: the domain to parse, if the domain is not a string it
+                       is assumed to be a literal domain and is returned as-is
         :param session: Current OpenERP session
         :type session: openerpweb.openerpweb.OpenERPSession
         """
@@ -805,8 +812,8 @@ class View(openerpweb.Controller):
         """ Parses an arbitrary string containing a context, transforms it
         to either a literal context or a :class:`openerpweb.nonliterals.Context`
 
-        :param context: the context to parse, if the context is not a string it is assumed to
-        be a literal domain and is returned as-is
+        :param context: the context to parse, if the context is not a string it
+               is assumed to be a literal domain and is returned as-is
         :param session: Current OpenERP session
         :type session: openerpweb.openerpweb.OpenERPSession
         """