Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
FUSS
fuss-utility
Commits
cf3e8b0c
Commit
cf3e8b0c
authored
Oct 29, 2019
by
Elena Grandi
Browse files
Load current locale using locale from the standard library.
parent
0921984a
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/set-session-language
View file @
cf3e8b0c
#!/usr/bin/env python3
import
locale
import
os.path
import
subprocess
import
tkinter
as
tk
...
...
@@ -28,24 +29,14 @@ class App(tk.Frame):
if
b
'utf8'
in
l
:
self
.
locales
.
append
(
l
.
decode
())
def
find_current_locale
(
self
):
cmd
=
"cat ~/.dmrc|grep Language|tr '=' ' '|awk '{print $2}'"
ps
=
subprocess
.
Popen
(
cmd
,
shell
=
True
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
output
=
ps
.
communicate
()[
0
]
self
.
curlocale
=
[]
for
l
in
output
.
split
(
b
'
\n
'
):
if
b
'utf8'
in
l
:
self
.
curlocale
.
append
(
l
.
decode
())
def
create_widgets
(
self
):
self
.
text
=
tk
.
Label
(
self
,
text
=
_
(
"Scegli la lingua per le prossime sessioni."
)
)
self
.
text
.
pack
(
side
=
"top"
)
self
.
chosen_locale
.
set
(
self
.
curlocale
[
0
])
cur_loc
=
locale
.
getlocale
()
self
.
chosen_locale
.
set
(
cur_loc
[
0
]
+
'.'
+
cur_loc
[
1
])
self
.
locale_menu
=
tk
.
OptionMenu
(
self
,
self
.
chosen_locale
,
*
self
.
locales
)
self
.
locale_menu
.
pack
(
side
=
"top"
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment