Browse Source

Gives the language parameter to templates

Adrien Panay 7 years ago
parent
commit
c682e33825

+ 11 - 0
tracim/tracim/lib/helpers.py View File

@@ -31,6 +31,17 @@ from tracim.model.data import UserRoleInWorkspace
31 31
 from tracim.model.data import Workspace
32 32
 
33 33
 
34
+def get_lang() -> str:
35
+    """
36
+    Gets language code.
37
+
38
+    Provides the first language:
39
+    - asked by the request to the server,
40
+    - supported by Tracim.
41
+    """
42
+    return tg.i18n.get_lang(all=False)[0]
43
+
44
+
34 45
 def get_with_timezone(
35 46
         datetime_object: datetime.datetime,
36 47
         to_timezone: str='',

+ 1 - 1
tracim/tracim/templates/master_anonymous.mak View File

@@ -14,7 +14,7 @@
14 14
         <link href="${tg.url('/assets/dist/all.css')}" rel="stylesheet">
15 15
 
16 16
         <script>
17
-          globalTracimLang = 'fr_FR'
17
+          globalTracimLang = ${h.get_lang()}
18 18
         </script>
19 19
     </head>
20 20
 

+ 1 - 1
tracim/tracim/templates/master_authenticated.mak View File

@@ -19,7 +19,7 @@
19 19
             window.addEventListener("hashchange", shiftWindow);
20 20
             function load() { if (window.location.hash) shiftWindow(); }
21 21
 
22
-            globalTracimLang = 'fr_FR'
22
+            globalTracimLang = ${h.get_lang()}
23 23
         </script>
24 24
         <link rel="manifest" href="manifest.json?v=0.0.1" />
25 25
     </head>

+ 1 - 1
tracim/tracim/templates/master_no_toolbar_no_login.mak View File

@@ -29,7 +29,7 @@
29 29
         <![endif]-->
30 30
 
31 31
         <script>
32
-          globalTracimLang = 'fr_FR'
32
+          globalTracimLang = ${h.get_lang()}
33 33
         </script>
34 34
     </head>
35 35