diff --git a/odoo_sentinel/__init__.py b/odoo_sentinel/__init__.py index 8c544f5..62a9207 100755 --- a/odoo_sentinel/__init__.py +++ b/odoo_sentinel/__init__.py @@ -57,6 +57,22 @@ def __init__(self, stdscr, options): """ Initialize the sentinel program """ + # Replace global dummy lambda by the translations gettext method + # The install method of gettext doesn't replace the function if exists + global _ + + # Initialize translations + lang = self.connection.env.context.get('lang', I18N_DEFAULT) + gettext.install(I18N_DOMAIN) + try: + language = gettext.translation( + I18N_DOMAIN, I18N_DIR, languages=[lang]) + except: + language = gettext.translation( + I18N_DOMAIN, I18N_DIR, languages=[I18N_DEFAULT]) + + _ = language.gettext + if options.profile in odoorpc.ODOO.list(rc_file=options.config_file): # Try to autodetect an OdooRPC configuration self.connection = odoorpc.ODOO.load(options.profile) @@ -71,21 +87,6 @@ def __init__(self, stdscr, options): if options.test_file: self.test_file = open(os.path.expanduser(options.test_file), 'r') - # Initialize translations - lang = self.connection.env.context.get('lang', I18N_DEFAULT) - gettext.install(I18N_DOMAIN) - try: - language = gettext.translation( - I18N_DOMAIN, I18N_DIR, languages=[lang]) - except: - language = gettext.translation( - I18N_DOMAIN, I18N_DIR, languages=[I18N_DEFAULT]) - - # Replace global dummy lambda by the translations gettext method - # The install method of gettext doesn't replace the function if exists - global _ - _ = language.gettext - # Initialize window self.screen = stdscr self._set_screen_size() @@ -838,7 +839,7 @@ def _menu_display(self, entries, highlighted, title=None): nb_lines, self.window_width - 1, curses.ACS_DARROW) # Diplays number of the selected entry - self._display(_('Selected : %d') % highlighted, y=self.window_height-1, + self._display(_('Selected : %d') % highlighted, y=self.window_height - 1, color='info', modifier=curses.A_BOLD) # Set the cursor position @@ -877,5 +878,6 @@ def main(): curses.wrapper(Sentinel, args) + if __name__ == '__main__': main()