Commit cf3e8b0c authored by Elena Grandi's avatar Elena Grandi
Browse files

Load current locale using locale from the standard library.

parent 0921984a
#!/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")
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment