i18n: Mark strings missed for translation

Helps: #1938.

    backups/forms.py:
	- ChoiceField labeled to allow translation.
	- Translation applied to hard coded literals.

    config/forms.py:
	Lazy translation applied to literals that were translated but still
	displayed in english to non-english users.

    diagnostics_results.html:
	Apply translation to results. Use gettext_noop to mark for translation.

    dynamicdns/forms.py:
	Apply translation to choice literals.

    i2p/views.py:
	Lazy translation applied to literals that were translated but still
	displayed in english to non-english users.

    names.html:
	Apply translation to table headers.

    performance/__init__.py:
	Apply translation to description literals.

    radicale/forms.py:
	ChoiceField labeled to allow translation.

    users/forms.py:
	CharField labeled to allow translation.

    QA:
	- Literals visually verified.
	- No errors in py.test-3.
	- Yapf applied (only) to changed files.
	- No remarks by flake8 to changed file.

Signed-off-by: Fioddor Superconcentrado <fioddor@gmail.com>
[sunil: Separate out the translations]
[sunil: Fix i18n for diagnostics]
[sunil: dynamicdns: Also do i18n for string GnuDIP]
[sunil: searx: Revert an incorrect removal of import]
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: Sunil Mohan Adapa <sunil@medhas.org>
This commit is contained in:
Fioddor Superconcentrado 2020-09-14 15:05:42 +02:00 committed by Sunil Mohan Adapa
parent 13998ea977
commit 43ab6db456
No known key found for this signature in database
GPG Key ID: 43EA1CFF0AA7C5F2
10 changed files with 36 additions and 24 deletions

View File

@ -47,7 +47,7 @@ def _get_repository_choices():
class CreateArchiveForm(forms.Form):
repository = forms.ChoiceField()
repository = forms.ChoiceField(label=_('Repository'))
name = forms.RegexField(
label=_('Name'),
help_text=_('(Optional) Set a name for this backup archive'),
@ -119,7 +119,7 @@ class EncryptedBackupsMixin(forms.Form):
label=_('Encryption'), help_text=format_lazy(
_('"Key in Repository" means that a '
'password-protected key is stored with the backup.')),
choices=[('repokey', 'Key in Repository'), ('none', 'None')])
choices=[('repokey', _('Key in Repository')), ('none', _('None'))])
encryption_passphrase = forms.CharField(
label=_('Passphrase'),
help_text=_('Passphrase; Only needed when using encryption.'),

View File

@ -88,6 +88,7 @@ class ConfigurationForm(forms.Form):
choices=get_homepage_choices)
advanced_mode = forms.BooleanField(
label=_('Show advanced apps and features'), required=False,
help_text=_('Show apps and features that require more technical '
'knowledge.'))
label=ugettext_lazy('Show advanced apps and features'), required=False,
help_text=ugettext_lazy(
'Show apps and features that require more technical '
'knowledge.'))

View File

@ -9,6 +9,7 @@ import logging
import threading
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext_noop
from plinth import app as app_module
from plinth import daemon, menu
@ -96,6 +97,12 @@ def run_on_all_enabled_modules():
'progress_percentage': 0
}
# Three result strings returned by tests, mark for translation and
# translate later.
ugettext_noop('passed')
ugettext_noop('failed')
ugettext_noop('error')
apps = []
for app in app_module.App.list():
# XXX: Implement more cleanly.

View File

@ -17,11 +17,11 @@
<td>{{ test }}</td>
<td>
{% if result == 'passed' %}
<span class="label label-success">{{ result }}</span>
<span class="label label-success">{% trans result %}</span>
{% elif result == 'failed' %}
<span class="label label-danger">{{ result }}</span>
<span class="label label-danger">{% trans result %}</span>
{% elif result == 'error' %}
<span class="label label-warning">{{ result }}</span>
<span class="label label-warning">{% trans result %}</span>
{% else %}
{{ result }}
{% endif %}

View File

@ -7,12 +7,14 @@ from django import forms
from django.core import validators
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy
from plinth import cfg
from plinth.utils import format_lazy
class TrimmedCharField(forms.CharField):
"""Trim the contents of a CharField."""
def clean(self, value):
"""Clean and validate the field value"""
if value:
@ -59,11 +61,11 @@ class ConfigureForm(forms.Form):
help_user = \
ugettext_lazy('The username that was used when the account was '
'created.')
"""ToDo: sync this list with the html template file"""
provider_choices = (('GnuDIP', 'GnuDIP'), ('noip', 'noip.com'),
('selfhost', 'selfhost.bz'), ('freedns',
'freedns.afraid.org'),
('other', 'other update URL'))
provider_choices = (('GnuDIP', ugettext_lazy('GnuDIP')),
('noip', 'noip.com'), ('selfhost', 'selfhost.bz'),
('freedns', 'freedns.afraid.org'),
('other', ugettext_lazy('other update URL')))
enabled = forms.BooleanField(label=ugettext_lazy('Enable Dynamic DNS'),
required=False)

View File

@ -3,7 +3,7 @@
Views for I2P application.
"""
from django.utils.translation import ugettext as _
from django.utils.translation import ugettext_lazy as _
from plinth.views import AppView

View File

@ -11,9 +11,9 @@
<table class="table table-bordered table-condensed table-striped names-table">
<thead>
<tr>
<th>Type</th>
<th class="names-domain-column">Domain Name</th>
<th>Services</th>
<th>{% trans "Type" %}</th>
<th class="names-domain-column">{% trans "Domain Name" %}</th>
<th>{% trans "Services" %}</th>
<th></th>
</tr>
</thead>

View File

@ -22,12 +22,12 @@ managed_services = [
managed_packages = ['cockpit-pcp']
_description = [
('Performance app allows you to collect, store and view information about '
'utilization of the hardware. This can give you basic insights into '
'usage patterns and whether the hardware is overloaded by users and '
'services.'),
('Performance metrics are collected by Performance Co-Pilot and can be '
'viewed using the Cockpit app.'),
_('Performance app allows you to collect, store and view information '
'about utilization of the hardware. This can give you basic insights '
'into usage patterns and whether the hardware is overloaded by users '
'and services.'),
_('Performance metrics are collected by Performance Co-Pilot and can be '
'viewed using the Cockpit app.'),
]
app = None

View File

@ -27,5 +27,6 @@ CHOICES = [
class RadicaleForm(forms.Form):
"""Specialized configuration form for radicale service."""
access_rights = forms.ChoiceField(choices=CHOICES, required=True,
access_rights = forms.ChoiceField(label=_('Access rights'),
choices=CHOICES, required=True,
widget=forms.RadioSelect())

View File

@ -65,6 +65,7 @@ class UsernameValidator(validators.RegexValidator):
USERNAME_FIELD = forms.CharField(
label=ugettext_lazy('Username'),
max_length=150, validators=[UsernameValidator()],
help_text=ugettext_lazy('Required. 150 characters or fewer. English '
'letters, digits and @/./-/_ only.'))