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
 from tracim.model.data import Workspace
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
 def get_with_timezone(
45
 def get_with_timezone(
35
         datetime_object: datetime.datetime,
46
         datetime_object: datetime.datetime,
36
         to_timezone: str='',
47
         to_timezone: str='',

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

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

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

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

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

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