Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F4880254
i18n.py
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
822 B
Subscribers
None
i18n.py
View Options
import
locale
import
json
import
os
def
load_language_list
(
language
):
with
open
(
f
"./lib/i18n/{language}.json"
,
"r"
,
encoding
=
"utf-8"
)
as
f
:
language_list
=
json
.
load
(
f
)
return
language_list
class
I18nAuto
:
def
__init__
(
self
,
language
=
None
):
if
language
in
[
"Auto"
,
None
]:
language
=
locale
.
getdefaultlocale
()[
0
]
# getlocale can't identify the system's language ((None, None))
if
not
os
.
path
.
exists
(
f
"./lib/i18n/{language}.json"
):
language
=
"en_US"
self
.
language
=
language
# print("Use Language:", language)
self
.
language_map
=
load_language_list
(
language
)
def
__call__
(
self
,
key
):
return
self
.
language_map
.
get
(
key
,
key
)
def
print
(
self
):
print
(
"Use Language:"
,
self
.
language
)
File Metadata
Details
Attached
Mime Type
text/x-python
Expires
Sun, Jan 12, 01:58 (1 d, 4 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1347131
Default Alt Text
i18n.py (822 B)
Attached To
R350 av_svc
Event Timeline
Log In to Comment