-
Notifications
You must be signed in to change notification settings - Fork 0
/
ml.py
executable file
·40 lines (31 loc) · 926 Bytes
/
ml.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/python3
# -*- coding: utf-8 -*-
lang = 'f' # default current language
allowed = 'efn'
def setLang(some_lang):
global lang, allowed
some_lang = some_lang.lower()
if some_lang in allowed:
lang = some_lang
return True
return False
# manages Multilinguism
# Initialized using t("français","english","nederlands")
# and accessed using .t property
class T(object):
def __init__(self,f=None,e=None,n=None):
self.french = f if f else (e if e else n)
self.english = e if e else (f if f else n)
self.dutch = n if n else (e if e else f)
def __str__(self):
global lang
if lang == 'f':
return self.french
elif lang == 'n':
return self.dutch
else:
return self.english
if __name__ == "__main__":
if setLang('n'):
print ('OK')
print (T("français","english","nederlands"))