-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
30 lines (24 loc) · 932 Bytes
/
main.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
#!/usr/bin/env python3
import gettext
'''
Switching Locale
You can switch locales in your program using Class based gettex API
The method gettext.translation accepts some parameters that can be used
to load the associated .mo files of a particular language.
If no .mo file is found, it raises an error
base => is the domain and the method will look for a .po
localedir => is the directory location of the locale folder you created
languages => is a hint for the searching mechanism to load particular language code more resiliently
'''
el = gettext.translation('base', localedir='locale', languages=['es'])
el.install()
_ = el.gettext
def say_hello():
'''
This is a short function when you write your name
yo can show a funny greeting :D
'''
name = input(_('What is your name?'))
print(_('Hello, {}. :D').format(name))
if __name__=='__main__':
say_hello()