Selaa lähdekoodia

Adds exception management in language code access

Adrien Panay 7 vuotta sitten
vanhempi
commit
7dfbab95ef
2 muutettua tiedostoa jossa 10 lisäystä ja 1 poistoa
  1. 1 0
      tracim/test.ini
  2. 9 1
      tracim/tracim/lib/helpers.py

+ 1 - 0
tracim/test.ini Näytä tiedosto

@@ -26,6 +26,7 @@ port = 8080
26 26
 # sqlalchemy.url = mysql+pymysql://tracimuser:tracimpassword@127.0.0.1/tracimdb_test
27 27
 sqlalchemy.url = sqlite:///tracimdb_test.sqlite
28 28
 use = config:development.ini
29
+lang = fr
29 30
 
30 31
 [app:main_without_authn]
31 32
 use = main

+ 9 - 1
tracim/tracim/lib/helpers.py Näytä tiedosto

@@ -36,7 +36,15 @@ def get_lang() -> str:
36 36
     - asked by the request to the server,
37 37
     - supported by Tracim.
38 38
     """
39
-    return tg.i18n.get_lang(all=False)[0]
39
+    # TODO - A.P - language code access from test environment
40
+    # try based workaround instead of raw get language call for test
41
+    # environment only, this should be set with tg.i18n.set_lang in
42
+    # be I was unable to achieve that.
43
+    try:
44
+        result = tg.i18n.get_lang(all=False)[0]
45
+    except:
46
+        result = 'en'
47
+    return result
40 48
 
41 49
 
42 50
 def get_with_timezone(