From: Eugene Gagarin Date: Wed, 29 Apr 2009 10:48:23 +0000 (+0400) Subject: Improving localization X-Git-Url: http://git.maemo.org/git/?p=findit;a=commitdiff_plain;h=8c7af31d3e716249fa8f9e8eb0d663f7c078b14d Improving localization --- diff --git a/src/files/outtable.py b/src/files/outtable.py index 9135445..b7219dc 100755 --- a/src/files/outtable.py +++ b/src/files/outtable.py @@ -2,6 +2,8 @@ # -*-coding: utf-8 -*- # vim: sw=4 ts=4 expandtab ai +from misc import _ + #============================================================================== # class OutTable_Control(object): diff --git a/src/files/search.py b/src/files/search.py index 4816c90..6b15c4b 100755 --- a/src/files/search.py +++ b/src/files/search.py @@ -6,7 +6,7 @@ from os import walk from os.path import join, abspath, normcase, basename, isdir, getsize from heapq import nlargest -from misc import * +from misc import size_hum_read, _ #============================================================================== diff --git a/src/main.py b/src/main.py index fb86578..cd1bafb 100755 --- a/src/main.py +++ b/src/main.py @@ -6,6 +6,7 @@ import sys from config import Config +from misc import _ __progname__ = 'FindIT' __version__ = '0.2.0' @@ -39,18 +40,6 @@ under the terms of the GNU General Public License\nas published by the Free \ Software Foundation; either version 3\nof the License, or (at your option) \ any later version.' - import gettext - try: - # Meaning ru/LC_MESSAGES/program.mo in current dir (sys.path[0]) - # For /usr/share/locale uncomment next string: - #LANGRU = gettext.translation('findit') - LANGRU = gettext.translation('findit', sys.path[0], languages=['ru']) - LANGRU.install() - except IOError: - # Comment out before use pygettext - def _(text): - return text - #============================================================================== class Cli_Presentation(object): diff --git a/src/misc.py b/src/misc.py index b807c1d..a8a964f 100755 --- a/src/misc.py +++ b/src/misc.py @@ -8,3 +8,22 @@ def size_hum_read(size): if size < 1024**(i+1): return unit % (size/1024.**i) return '>1024 Tb' + +#============================================================================== + +import sys +import gettext +import os + +os.environ['LANGUAGE'] = 'ru' ### + +try: + # Meaning ru/LC_MESSAGES/findit.mo is in current dir (sys.path[0]) + # For /usr/share/locale write `gettext.bindtextdomain('findit')`: + gettext.bindtextdomain('findit', sys.path[0]) + gettext.textdomain('findit') + _ = gettext.gettext +except IOError: + # Comment out before use pygettext + def _(text): + return text