Index: elogv =================================================================== --- elogv (wersja 442) +++ elogv (kopia robocza) @@ -27,9 +27,21 @@ import curses.ascii from portage import settings as port_settings from glob import glob +import gettext +import locale +# Setup default locale +locale.setlocale(locale.LC_ALL, '') + +# Setup gettext. Note that lgettext() is used instead of gettext() +# because it always returns strings encoded with the preferred system +# encoding, not encoded with the same codeset used in the translation +# file +gettext.textdomain('elogv') +_ = gettext.lgettext + # This text is used on the in-line help -helptext = """ +helptext = _(""" Elogv is a portage elog viewer based on curses and python, you can use these keys to control the behavior of the program: @@ -55,7 +67,7 @@ - / -> starts a search prompt, write a string and will be showed the next package that contains your string, use ESC to exit - q -> quit -""" +""") (normal,selected,einfo,ewarn,eerror,elog) = range(6) @@ -218,7 +230,7 @@ # Screen Look&Feel self.screen.border() self.screen.hline(self.height/2,1, "_", self.width-2) - m = " Press F1 or h to show the help screen " + m = _(" Press F1 or h to show the help screen ") self.screen.addstr(self.height-1, self.width-len(m)-1, m) self.screen.refresh() @@ -402,7 +414,7 @@ pass if self.f: - self.log_win.addstr(self.height/2-3, self.width-15, "Continue...", + self.log_win.addstr(self.height/2-3, self.width-15, _("Continue..."), curses.color_pair(normal)) self.log_win.refresh() @@ -477,9 +489,9 @@ self.change_usel(self.packages.index(x),False) break else: - self.screen.addstr(self.height-2,2,"Not Found!", + self.screen.addstr(self.height-2,2,_("Not Found!"), curses.color_pair(eerror)) - + if __name__ == "__main__": if "--help" in sys.argv: print helptext @@ -495,14 +507,14 @@ try: curses.wrapper(ElogViewer) except TermTooSmall: - print "Your terminal window is too small, try to enlarge it" + print _("Your terminal window is too small, try to enlarge it") sys.exit(1) except NoLogFiles: - print "There aren't any elog files on",elogdir + print _("There aren't any elog files on"),elogdir sys.exit(1) except CannotOpenElogdir: - print "Cannot open",elogdir - print "Please check if the directory exists and if it's readable by your user." + print _("Cannot open"),elogdir + print _("Please check if the directory exists and if it's readable by your user.") sys.exit(1) except KeyboardInterrupt: pass