Skip to content

Commit

Permalink
Rework translation for panel and dashboard names. Marked more strings.
Browse files Browse the repository at this point in the history
Uses ugettext_lazy to delay translation; reworks the __repr__
method to avoid using the translated form; and changes the
unicode method of the HorizonComponent class to actually return a
string coerced to unicode rather than a proxy object.

In the process, many more strings which had been missed have been
marked for translation.

Fixes bug 910297.

Change-Id: Ie8d10a928b0419313e6c54b0eff7a3a37299ca83
  • Loading branch information
gabrielhurley committed Mar 23, 2012
1 parent 67f3663 commit ab71aff
Show file tree
Hide file tree
Showing 53 changed files with 1,430 additions and 1,079 deletions.
11 changes: 6 additions & 5 deletions horizon/base.py
Expand Up @@ -75,7 +75,8 @@ def __init__(self):
% self.__class__)

def __unicode__(self):
return getattr(self, 'name', u"Unnamed %s" % self.__class__.__name__)
name = getattr(self, 'name', u"Unnamed %s" % self.__class__.__name__)
return unicode(name)

def _get_default_urlpatterns(self):
package_string = '.'.join(self.__module__.split('.')[:-1])
Expand Down Expand Up @@ -154,7 +155,7 @@ def _registered(self, cls):
% {"type": class_name,
"slug": cls,
"parent": parent,
"name": self.name})
"name": self.slug})
else:
slug = getattr(cls, "slug", cls)
raise NotRegistered('%(type)s with slug "%(slug)s" is not '
Expand Down Expand Up @@ -220,7 +221,7 @@ class Panel(HorizonComponent):
index_url_name = "index"

def __repr__(self):
return "<Panel: %s>" % self.__unicode__()
return "<Panel: %s>" % self.slug

def get_absolute_url(self):
""" Returns the default URL for this panel.
Expand Down Expand Up @@ -351,7 +352,7 @@ class Syspanel(horizon.Dashboard):
public = False

def __repr__(self):
return "<Dashboard: %s>" % self.__unicode__()
return "<Dashboard: %s>" % self.slug

def get_panel(self, panel):
"""
Expand Down Expand Up @@ -499,7 +500,7 @@ class Site(Registry, HorizonComponent):
urls = 'horizon.site_urls'

def __repr__(self):
return u"<Site: %s>" % self.__unicode__()
return u"<Site: %s>" % self.slug

@property
def _conf(self):
Expand Down
Expand Up @@ -36,9 +36,10 @@

class FloatingIpAssociate(forms.SelfHandlingForm):
floating_ip_id = forms.CharField(widget=forms.HiddenInput())
floating_ip = forms.CharField(widget=forms.TextInput(
floating_ip = forms.CharField(label=_("Floating IP"),
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
instance_id = forms.ChoiceField()
instance_id = forms.ChoiceField(label=_("Instance ID"))

def __init__(self, *args, **kwargs):
super(FloatingIpAssociate, self).__init__(*args, **kwargs)
Expand Down Expand Up @@ -72,7 +73,7 @@ def handle(self, request, data):

class FloatingIpAllocate(forms.SelfHandlingForm):
tenant_name = forms.CharField(widget=forms.HiddenInput())
pool = forms.ChoiceField()
pool = forms.ChoiceField(label=_("Pool"))

def __init__(self, *args, **kwargs):
super(FloatingIpAllocate, self).__init__(*args, **kwargs)
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/nova/access_and_security/panel.py
Expand Up @@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.nova import dashboard
Expand Down
Expand Up @@ -38,8 +38,9 @@


class CreateGroup(forms.SelfHandlingForm):
name = forms.CharField(validators=[validators.validate_slug])
description = forms.CharField()
name = forms.CharField(label=_("Name"),
validators=[validators.validate_slug])
description = forms.CharField(label=_("Description"))

def handle(self, request, data):
try:
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/nova/containers/panel.py
Expand Up @@ -18,7 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.nova import dashboard
Expand Down
4 changes: 2 additions & 2 deletions horizon/dashboards/nova/dashboard.py
Expand Up @@ -14,13 +14,13 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon


class Nova(horizon.Dashboard):
name = "Project"
name = _("Project")
slug = "nova"
panels = {_("Manage Compute"): ('overview',
'instances_and_volumes',
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/nova/images_and_snapshots/panel.py
Expand Up @@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.nova import dashboard
Expand Down
Expand Up @@ -35,8 +35,9 @@

class CreateSnapshot(forms.SelfHandlingForm):
tenant_id = forms.CharField(widget=forms.HiddenInput())
instance_id = forms.CharField(widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
instance_id = forms.CharField(label=_("Instance ID"),
widget=forms.TextInput(
attrs={'readonly': 'readonly'}))
name = forms.CharField(max_length="20", label=_("Snapshot Name"))

def handle(self, request, data):
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/nova/instances_and_volumes/panel.py
Expand Up @@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.nova import dashboard
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/nova/overview/panel.py
Expand Up @@ -18,7 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.nova import dashboard
Expand Down
Expand Up @@ -4,7 +4,7 @@
{% block form_id %}create_container_form{% endblock %}
{% block form_action %}{% url horizon:nova:containers:create %}{% endblock %}

{% block modal-header %}Create Container{% endblock %}
{% block modal-header %}{% trans "Create Container" %}{% endblock %}

{% block modal-body %}
<div class="left">
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/nova/templates/nova/objects/_copy.html
Expand Up @@ -4,7 +4,7 @@
{% block form_id %}copy_object_form{% endblock %}
{% block form_action %}{% url horizon:nova:containers:object_copy container_name object_name %}{% endblock %}

{% block modal-header %}Copy Object: {{ object_name }}{% endblock %}
{% block modal-header %}{% trans "Copy Object" %}: {{ object_name }}{% endblock %}

{% block modal-body %}
<div class="left">
Expand Down
Expand Up @@ -5,7 +5,7 @@
{% block form_action %}{% url horizon:nova:containers:object_upload container_name %}{% endblock %}
{% block form_attrs %}enctype="multipart/form-data"{% endblock %}

{% block modal-header %}Upload Object To Container: {{ container_name }}{% endblock %}
{% block modal-header %}{% trans "Upload Object To Container" %}: {{ container_name }}{% endblock %}

{% block modal-body %}
<div class="left">
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/nova/templates/nova/objects/copy.html
@@ -1,6 +1,6 @@
{% extends 'nova/base.html' %}
{% load i18n %}
{% block title %}Copy Object{% endblock %}
{% block title %}{% trans "Copy Object" %}{% endblock %}

{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Copy Object") %}
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/nova/templates/nova/objects/index.html
@@ -1,6 +1,6 @@
{% extends 'nova/base.html' %}
{% load i18n %}
{% block title %}Objects{% endblock %}
{% block title %}{% trans "Objects" %}{% endblock %}

{% block page_header %}
<div class='page-header'>
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/nova/templates/nova/objects/upload.html
@@ -1,6 +1,6 @@
{% extends 'nova/base.html' %}
{% load i18n %}
{% block title %}Upload Object{% endblock %}
{% block title %}{% trans "Upload Object" %}{% endblock %}

{% block page_header %}
{% include "horizon/common/_page_header.html" with title=_("Upload Objects") %}
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/settings/dashboard.py
Expand Up @@ -15,7 +15,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon

Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/settings/ec2/forms.py
Expand Up @@ -21,7 +21,7 @@

from django import http
from django.template.loader import render_to_string
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

from horizon import api
from horizon import exceptions
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/settings/ec2/panel.py
Expand Up @@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.settings import dashboard
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/settings/project/forms.py
Expand Up @@ -22,7 +22,7 @@

from django import shortcuts
from django.contrib import messages
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

from horizon import api
from horizon import forms
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/settings/project/panel.py
Expand Up @@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.settings import dashboard
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/settings/user/panel.py
Expand Up @@ -14,7 +14,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.settings import dashboard
Expand Down
4 changes: 2 additions & 2 deletions horizon/dashboards/syspanel/dashboard.py
Expand Up @@ -14,13 +14,13 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon


class Syspanel(horizon.Dashboard):
name = "Admin" # Appears in navigation
name = _("Admin")
slug = "syspanel"
panels = {_("System Panel"): ('overview', 'instances', 'services',
'flavors', 'images', 'projects', 'users',
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/syspanel/flavors/panel.py
Expand Up @@ -18,7 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.syspanel import dashboard
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/syspanel/images/panel.py
Expand Up @@ -18,7 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.syspanel import dashboard
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/syspanel/instances/panel.py
Expand Up @@ -18,7 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.syspanel import dashboard
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/syspanel/overview/panel.py
Expand Up @@ -18,7 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.syspanel import dashboard
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/syspanel/projects/panel.py
Expand Up @@ -18,7 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.syspanel import dashboard
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/syspanel/quotas/panel.py
Expand Up @@ -18,7 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.syspanel import dashboard
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/syspanel/services/panel.py
Expand Up @@ -18,7 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.syspanel import dashboard
Expand Down
2 changes: 1 addition & 1 deletion horizon/dashboards/syspanel/users/panel.py
Expand Up @@ -18,7 +18,7 @@
# License for the specific language governing permissions and limitations
# under the License.

from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _

import horizon
from horizon.dashboards.syspanel import dashboard
Expand Down

0 comments on commit ab71aff

Please sign in to comment.