|
|
1f1d7d |
diff --git a/test/misc-tests.py b/test/misc-tests.py
|
|
|
1f1d7d |
index 7d7d06f..11fd041 100644
|
|
|
1f1d7d |
--- a/test/misc-tests.py
|
|
|
1f1d7d |
+++ b/test/misc-tests.py
|
|
|
1f1d7d |
@@ -150,6 +150,19 @@ class MiscTests(DepsolveTests):
|
|
|
1f1d7d |
self.assertEqual(type(actual), type(expected))
|
|
|
1f1d7d |
self.assertEqual(actual, expected)
|
|
|
1f1d7d |
|
|
|
1f1d7d |
+ def testOptparse(self):
|
|
|
1f1d7d |
+ # make 'Usage: %s\n' translated
|
|
|
1f1d7d |
+ import gettext
|
|
|
1f1d7d |
+ def dgettext(domain, msg, orig=gettext.dgettext):
|
|
|
1f1d7d |
+ if domain=='messages' and msg == 'Usage: %s\n':
|
|
|
1f1d7d |
+ return 'Pou\xc5\xbeit\xc3\xad: %s\n'
|
|
|
1f1d7d |
+ return orig(domain, msg)
|
|
|
1f1d7d |
+ gettext.dgettext = dgettext
|
|
|
1f1d7d |
+ # run "yum --help"
|
|
|
1f1d7d |
+ from optparse import OptionParser
|
|
|
1f1d7d |
+ parser = OptionParser(usage=u'\u011b\u0161\u010d')
|
|
|
1f1d7d |
+ self.assertRaises(SystemExit, parser.parse_args, args=['--help'])
|
|
|
1f1d7d |
+
|
|
|
1f1d7d |
def setup_logging():
|
|
|
1f1d7d |
logging.basicConfig()
|
|
|
1f1d7d |
plainformatter = logging.Formatter("%(message)s")
|
|
|
1f1d7d |
diff --git a/yum/i18n.py b/yum/i18n.py
|
|
|
1f1d7d |
index 76a258d..2c0cbce 100755
|
|
|
1f1d7d |
--- a/yum/i18n.py
|
|
|
1f1d7d |
+++ b/yum/i18n.py
|
|
|
1f1d7d |
@@ -500,6 +500,14 @@ try:
|
|
|
1f1d7d |
t = gettext.translation('yum', fallback=True)
|
|
|
1f1d7d |
_ = t.ugettext
|
|
|
1f1d7d |
P_ = t.ungettext
|
|
|
1f1d7d |
+
|
|
|
1f1d7d |
+ # we describe yum commands and options with unicode but optparse
|
|
|
1f1d7d |
+ # mixes this with non-unicode translations so "yum --help" may fail.
|
|
|
1f1d7d |
+ # It's much easier to fix this in optparse than in yum. BZ 1033416
|
|
|
1f1d7d |
+ import optparse
|
|
|
1f1d7d |
+ if optparse._ is gettext.gettext:
|
|
|
1f1d7d |
+ #optparse._ = lambda msg: to_unicode(gettext.gettext(msg))
|
|
|
1f1d7d |
+ optparse._ = gettext.translation('messages', fallback=True).ugettext
|
|
|
1f1d7d |
except:
|
|
|
1f1d7d |
'''
|
|
|
1f1d7d |
Something went wrong so we make a dummy _() wrapper there is just
|