newfol: add basic gettext support.
Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
This commit is contained in:
parent
69f7cd5be2
commit
21b8a44ccb
1 changed files with 7 additions and 4 deletions
11
newfol
11
newfol
|
|
@ -3,25 +3,28 @@
|
|||
import sys
|
||||
sys.path.insert(0, sys.path[0] + "/lib")
|
||||
|
||||
import gettext
|
||||
import locale
|
||||
|
||||
import newfol.exception
|
||||
import newfol.main
|
||||
|
||||
from gettext import gettext as _
|
||||
from newfol.exception import LocaleError
|
||||
|
||||
if __name__ == '__main__':
|
||||
try:
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
gettext.bindtextdomain('newfol')
|
||||
if locale.getpreferredencoding(False) != 'UTF-8':
|
||||
raise LocaleError('Locale character set is not UTF-8')
|
||||
raise LocaleError(_('Locale character set is not UTF-8'))
|
||||
newfol.main.main(sys.argv[1:])
|
||||
except newfol.exception.NewfolError as e:
|
||||
sys.stderr.write("E: {0}\n".format(str(e)))
|
||||
sys.stderr.write(_("E: %s\n") % e)
|
||||
sys.exit(2)
|
||||
except newfol.exception.UpgradeNeededError as e:
|
||||
sys.stderr.write("E: {0}; try upgrading\n".format(str(e)))
|
||||
sys.stderr.write(_("E: %s; try upgrading\n") % e)
|
||||
sys.exit(2)
|
||||
except newfol.exception.FilemanipError as e:
|
||||
sys.stderr.write("E: {0}\n".format(str(e)))
|
||||
sys.stderr.write(_("E: %s\n") % e)
|
||||
sys.exit(2)
|
||||
|
|
|
|||
Loading…
Reference in a new issue