From 8d7f0a01aa7b8b213eefacc8974b2cb812460986 Mon Sep 17 00:00:00 2001 From: Gobinath Date: Thu, 9 Feb 2017 21:29:20 -0500 Subject: [PATCH] Bug fix in translating tray menu --- safeeyes/safeeyes/TrayIcon.py | 26 ++++++++++++++++---------- safeeyes/safeeyes/config/lang/ta.json | 12 ++++++------ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/safeeyes/safeeyes/TrayIcon.py b/safeeyes/safeeyes/TrayIcon.py index 62ce90f..2774fd8 100644 --- a/safeeyes/safeeyes/TrayIcon.py +++ b/safeeyes/safeeyes/TrayIcon.py @@ -62,6 +62,7 @@ class TrayIcon: self.item_enable.connect('activate', self.on_toogle_enable) self.sub_menu_disable = Gtk.Menu() + self.sub_menu_items = [] # Read disable options and build the sub menu for disable_option in config['disable_options']: @@ -85,14 +86,13 @@ class TrayIcon: # Create submenu sub_menu_item = Gtk.MenuItem() sub_menu_item.connect('activate', self.on_toogle_enable, time_in_minutes) - sub_menu_item.set_label(self.language['ui_controls'][disable_option['label']].format(disable_option['time'])) + self.sub_menu_items.append([sub_menu_item, disable_option['label'], disable_option['time']]) self.sub_menu_disable.append(sub_menu_item) # Disable until restart submenu - sub_menu_item = Gtk.MenuItem() - sub_menu_item.connect('activate', self.on_toogle_enable, -1) - sub_menu_item.set_label(self.language['ui_controls']['until_restart']) - self.sub_menu_disable.append(sub_menu_item) + self.sub_menu_item_until_restart = Gtk.MenuItem() + self.sub_menu_item_until_restart.connect('activate', self.on_toogle_enable, -1) + self.sub_menu_disable.append(self.sub_menu_item_until_restart) # Add the sub menu to the enable/disable menu self.item_enable.set_submenu(self.sub_menu_disable) @@ -109,11 +109,7 @@ class TrayIcon: self.item_quit = Gtk.MenuItem() self.item_quit.connect('activate', self.quit_safe_eyes) - self.item_info.set_label(self.language['messages']['disabled_until_restart']) - self.item_enable.set_label(self.language['ui_controls']['disable']) - self.item_settings.set_label(self.language['ui_controls']['settings']) - self.item_about.set_label(self.language['ui_controls']['about']) - self.item_quit.set_label(self.language['ui_controls']['quit']) + self.set_labels(language) # Append all menu items and show the menu self.menu.append(self.item_info) @@ -126,6 +122,16 @@ class TrayIcon: self.indicator.set_menu(self.menu) + def set_labels(self, language): + self.language = language + for entry in self.sub_menu_items: + entry[0].set_label(self.language['ui_controls'][entry[1]].format(entry[2])) + self.sub_menu_item_until_restart.set_label(self.language['ui_controls']['until_restart']) + self.item_info.set_label(self.language['messages']['disabled_until_restart']) + self.item_enable.set_label(self.language['ui_controls']['disable']) + self.item_settings.set_label(self.language['ui_controls']['settings']) + self.item_about.set_label(self.language['ui_controls']['about']) + self.item_quit.set_label(self.language['ui_controls']['quit']) def show_icon(self): Utility.execute_main_thread(self.indicator.set_status, appindicator.IndicatorStatus.ACTIVE) diff --git a/safeeyes/safeeyes/config/lang/ta.json b/safeeyes/safeeyes/config/lang/ta.json index 43b8a5d..251de4f 100644 --- a/safeeyes/safeeyes/config/lang/ta.json +++ b/safeeyes/safeeyes/config/lang/ta.json @@ -26,12 +26,12 @@ }, "ui_controls": { "cancel": "ரத்து", - "enable": "Safe Eyes செயல்படுகிறது", - "disable": "Disable Safe Eyes", - "for_x_minutes": "For {} Minutes", - "for_x_hour": "For {} Hour", - "for_x_hours": "For {} Hours", - "until_restart": "Until restart", + "enable": "Safe Eyes ஐ செயல்படுத்துக", + "disable": "Safe Eyes ஐ நிறுத்துக", + "for_x_minutes": "{} நிமிடங்களுக்கு", + "for_x_hour": "{} மணித்தியாலத்திற்கு", + "for_x_hours": "{} மணித்தியாலங்களுக்கு", + "until_restart": "மீள ஆரம்பிக்கும் வரைை", "interval_between_two_breaks": "இரண்டு இடைவேளைகளுக்கிடையிலான இடைவெளி (விநாடிகளில்)", "long_break_duration": "நீண்ட கால இடைவேளை (விநாடிகளில்)", "idle_time": "இடைநிறுத்துவதற்கான குறைந்தபட்ச செயலற்ற நேரம் (நிமிடங்களில்)",