Commit 1f05a790 authored by Daniel Garcia Moreno's avatar Daniel Garcia Moreno

i18n: Setting locale in main_window

Fix #7
parent 97628678
Pipeline #55960 passed with stage
in 59 seconds
......@@ -2,6 +2,7 @@
"app-id": "net.danigm.timetrackDevel",
"runtime" : "org.gnome.Platform",
"runtime-version" : "master",
"separate-locales": false,
"sdk" : "org.gnome.Sdk",
"tags" : [
"devel",
......
......@@ -45,7 +45,7 @@ if __name__ == "__main__":
else:
Application.development_mode = False
app = Application()
app = Application(localedir=localedir)
exit_status = app.run(sys.argv)
sys.exit(exit_status)
......@@ -15,8 +15,10 @@ class Application(Gtk.Application):
development_mode = False
application_id = "net.danigm.timetrack"
db = NotImplemented
localedir = None
def __init__(self, *args, **kwargs):
self.localedir = kwargs.pop('localedir')
super().__init__(
*args, application_id=self.application_id, flags=Gio.ApplicationFlags.HANDLES_OPEN)
Handy.init()
......@@ -34,6 +36,7 @@ class Application(Gtk.Application):
def do_activate(self):
if not self.window:
self.window = MainWindow(
localedir=self.localedir,
application=self, title="Timetrack",
icon_name=self.application_id)
......
from functools import partial
import locale
from gettext import gettext as _
from gi.repository import Gio, GLib, Gdk, Gtk, Handy
......@@ -73,6 +74,11 @@ class MainWindow(Gtk.ApplicationWindow):
current_day = NotImplemented
def __init__(self, *args, **kwargs):
self.localedir = kwargs.pop('localedir')
if self.localedir:
locale.bindtextdomain('timetrack', self.localedir)
locale.textdomain('timetrack')
super().__init__(*args, **kwargs)
self.logging_manager = kwargs['application'].get_logger()
......
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