Force translation of table header

Concatenation of lazily translated strings using + is not supported,
but prettytable is doing that internally with one of the translated
strings that we pass in. Use six.text_type to force immediate
translation of the string before passing it to prettytable.

Change-Id: I73929f9df85a9856bb70b37ee08f5399f98fdb00
Closes-Bug: 1801761
This commit is contained in:
Ben Nemec 2018-11-05 17:09:58 +00:00
parent 452bd23954
commit c4283dd0eb
1 changed files with 6 additions and 1 deletions

View File

@ -20,6 +20,7 @@ import traceback
import enum import enum
from oslo_config import cfg from oslo_config import cfg
import prettytable import prettytable
import six
from oslo_upgradecheck._i18n import _ from oslo_upgradecheck._i18n import _
@ -116,7 +117,11 @@ class UpgradeCommands(object):
# | Details: There is no placement-api endpoint in the | # | Details: There is no placement-api endpoint in the |
# | service catalog. | # | service catalog. |
# +----------------------------------------------------+ # +----------------------------------------------------+
t = prettytable.PrettyTable([_('Upgrade Check Results')], # NOTE(bnemec): We use six.text_type on the translated string to
# force immediate translation if lazy translation is in use.
# See lp1801761 for details.
t = prettytable.PrettyTable([six.text_type(_('Upgrade Check Results'))
],
hrules=prettytable.ALL) hrules=prettytable.ALL)
t.align = 'l' t.align = 'l'
for name, result in check_results: for name, result in check_results: