diff --git a/openstack_dashboard/dashboards/admin/overview/views.py b/openstack_dashboard/dashboards/admin/overview/views.py index a79892882b..ab5093fb92 100644 --- a/openstack_dashboard/dashboards/admin/overview/views.py +++ b/openstack_dashboard/dashboards/admin/overview/views.py @@ -18,7 +18,7 @@ from django.conf import settings from django.template.defaultfilters import floatformat -from django.utils import translation +from django.utils.text import format_lazy from django.utils.translation import ugettext_lazy as _ from horizon import exceptions @@ -71,6 +71,7 @@ class GlobalOverview(usage.UsageView): instance.project_name = getattr(project[0], "name", None) else: deleted = _("Deleted") - instance.project_name = translation.string_concat( - instance.tenant_id, " (", deleted, ")") + instance.project_name = format_lazy( + '{tenant_id} ({deleted})', + tenant_id=instance.tenant_id, deleted=deleted) return data diff --git a/openstack_dashboard/dashboards/project/floating_ips/tables.py b/openstack_dashboard/dashboards/project/floating_ips/tables.py index c1926e76b7..fe0984491a 100644 --- a/openstack_dashboard/dashboards/project/floating_ips/tables.py +++ b/openstack_dashboard/dashboards/project/floating_ips/tables.py @@ -18,8 +18,8 @@ import logging from django import shortcuts from django.urls import reverse from django.utils.http import urlencode +from django.utils.text import format_lazy from django.utils.translation import pgettext_lazy -from django.utils.translation import string_concat from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy @@ -52,8 +52,10 @@ class AllocateIP(tables.LinkAction): if usages['floatingip']['available'] <= 0: if "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] - self.verbose_name = string_concat(self.verbose_name, ' ', - _("(Quota exceeded)")) + self.verbose_name = format_lazy( + '{verbose_name} {quota_exceeded}', + verbose_name=self.verbose_name, + quota_exceeded=_("(Quota exceeded)")) else: self.verbose_name = _("Allocate IP To Project") classes = [c for c in self.classes if c != "disabled"] diff --git a/openstack_dashboard/dashboards/project/instances/tables.py b/openstack_dashboard/dashboards/project/instances/tables.py index 875985bc3e..d12c8bebf6 100644 --- a/openstack_dashboard/dashboards/project/instances/tables.py +++ b/openstack_dashboard/dashboards/project/instances/tables.py @@ -23,9 +23,9 @@ from django.template.defaultfilters import title from django import urls from django.utils.http import urlencode from django.utils.safestring import mark_safe +from django.utils.text import format_lazy from django.utils.translation import npgettext_lazy from django.utils.translation import pgettext_lazy -from django.utils.translation import string_concat from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy import netaddr @@ -449,8 +449,10 @@ class LaunchLink(tables.LinkAction): or ram_available <= 0: if "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] - self.verbose_name = string_concat(self.verbose_name, ' ', - _("(Quota exceeded)")) + self.verbose_name = format_lazy( + '{verbose_name} {quota_exceeded}', + verbose_name=self.verbose_name, + quota_exceeded=_("(Quota exceeded)")) else: self.verbose_name = _("Launch Instance") classes = [c for c in self.classes if c != "disabled"] @@ -772,7 +774,8 @@ def get_instance_error(instance): message = instance_fault_to_friendly_message(instance) preamble = _('Failed to perform requested operation on instance "%s", the ' 'instance has an error status') % instance.name or instance.id - message = string_concat(preamble, ': ', message) + message = format_lazy('{preamble}: {message}', + preamble=preamble, message=message) return message diff --git a/openstack_dashboard/dashboards/project/key_pairs/tables.py b/openstack_dashboard/dashboards/project/key_pairs/tables.py index 14b6df0d00..b94e20ca66 100644 --- a/openstack_dashboard/dashboards/project/key_pairs/tables.py +++ b/openstack_dashboard/dashboards/project/key_pairs/tables.py @@ -13,7 +13,7 @@ # under the License. from django import urls -from django.utils.translation import string_concat +from django.utils.text import format_lazy from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy from six.moves.urllib import parse @@ -57,8 +57,10 @@ class QuotaKeypairMixin(object): if usages['key_pairs']['available'] <= 0: if "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] - self.verbose_name = string_concat(self.verbose_name, ' ', - _("(Quota exceeded)")) + self.verbose_name = format_lazy( + '{verbose_name} {quota_exceeded}', + verbose_name=self.verbose_name, + quota_exceeded=_("(Quota exceeded)")) return False else: classes = [c for c in self.classes if c != "disabled"] diff --git a/openstack_dashboard/dashboards/project/volumes/tables.py b/openstack_dashboard/dashboards/project/volumes/tables.py index d64f8c5d83..51f02d3a1d 100644 --- a/openstack_dashboard/dashboards/project/volumes/tables.py +++ b/openstack_dashboard/dashboards/project/volumes/tables.py @@ -20,9 +20,9 @@ from django.urls import reverse from django.utils import html from django.utils.http import urlencode from django.utils import safestring +from django.utils.text import format_lazy from django.utils.translation import npgettext_lazy from django.utils.translation import pgettext_lazy -from django.utils.translation import string_concat from django.utils.translation import ugettext_lazy as _ from django.utils.translation import ungettext_lazy @@ -153,8 +153,10 @@ class CreateVolume(tables.LinkAction): if gb_available <= 0 or volumes_available <= 0: if "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] - self.verbose_name = string_concat(self.verbose_name, ' ', - _("(Quota exceeded)")) + self.verbose_name = format_lazy( + '{verbose_name} {quota_exceeded}', + verbose_name=self.verbose_name, + quota_exceeded=_("(Quota exceeded)")) else: self.verbose_name = _("Create Volume") classes = [c for c in self.classes if c != "disabled"] @@ -226,8 +228,10 @@ class CreateSnapshot(VolumePolicyTargetMixin, tables.LinkAction): if snapshots_available <= 0 and "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] - self.verbose_name = string_concat(self.verbose_name, ' ', - _("(Quota exceeded)")) + self.verbose_name = format_lazy( + '{verbose_name} {quota_exceeded}', + verbose_name=self.verbose_name, + quota_exceeded=_("(Quota exceeded)")) return volume.status in ("available", "in-use") @@ -312,8 +316,10 @@ class AcceptTransfer(tables.LinkAction): if gb_available <= 0 or volumes_available <= 0: if "disabled" not in self.classes: self.classes = [c for c in self.classes] + ['disabled'] - self.verbose_name = string_concat(self.verbose_name, ' ', - _("(Quota exceeded)")) + self.verbose_name = format_lazy( + '{verbose_name} {quota_exceeded}', + verbose_name=self.verbose_name, + quota_exceeded=_("(Quota exceeded)")) else: self.verbose_name = _("Accept Transfer") classes = [c for c in self.classes if c != "disabled"]