From 43ab6db456e96e4ebe42f29a3f0593bf6c762d16 Mon Sep 17 00:00:00 2001 From: Fioddor Superconcentrado Date: Mon, 14 Sep 2020 15:05:42 +0200 Subject: [PATCH] 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 [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 Reviewed-by: Sunil Mohan Adapa --- plinth/modules/backups/forms.py | 4 ++-- plinth/modules/config/forms.py | 7 ++++--- plinth/modules/diagnostics/__init__.py | 7 +++++++ .../diagnostics/templates/diagnostics_results.html | 6 +++--- plinth/modules/dynamicdns/forms.py | 12 +++++++----- plinth/modules/i2p/views.py | 2 +- plinth/modules/names/templates/names.html | 6 +++--- plinth/modules/performance/__init__.py | 12 ++++++------ plinth/modules/radicale/forms.py | 3 ++- plinth/modules/users/forms.py | 1 + 10 files changed, 36 insertions(+), 24 deletions(-) diff --git a/plinth/modules/backups/forms.py b/plinth/modules/backups/forms.py index 32f4bc23e..08e813097 100644 --- a/plinth/modules/backups/forms.py +++ b/plinth/modules/backups/forms.py @@ -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.'), diff --git a/plinth/modules/config/forms.py b/plinth/modules/config/forms.py index 70f4dfed1..2194a0a7f 100644 --- a/plinth/modules/config/forms.py +++ b/plinth/modules/config/forms.py @@ -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.')) diff --git a/plinth/modules/diagnostics/__init__.py b/plinth/modules/diagnostics/__init__.py index 80e4aec18..1984338dd 100644 --- a/plinth/modules/diagnostics/__init__.py +++ b/plinth/modules/diagnostics/__init__.py @@ -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. diff --git a/plinth/modules/diagnostics/templates/diagnostics_results.html b/plinth/modules/diagnostics/templates/diagnostics_results.html index 3dae9fe44..04c684b93 100644 --- a/plinth/modules/diagnostics/templates/diagnostics_results.html +++ b/plinth/modules/diagnostics/templates/diagnostics_results.html @@ -17,11 +17,11 @@ {{ test }} {% if result == 'passed' %} - {{ result }} + {% trans result %} {% elif result == 'failed' %} - {{ result }} + {% trans result %} {% elif result == 'error' %} - {{ result }} + {% trans result %} {% else %} {{ result }} {% endif %} diff --git a/plinth/modules/dynamicdns/forms.py b/plinth/modules/dynamicdns/forms.py index 918bf7f5e..e4344a85a 100644 --- a/plinth/modules/dynamicdns/forms.py +++ b/plinth/modules/dynamicdns/forms.py @@ -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) diff --git a/plinth/modules/i2p/views.py b/plinth/modules/i2p/views.py index 181316d1a..31a97e13f 100644 --- a/plinth/modules/i2p/views.py +++ b/plinth/modules/i2p/views.py @@ -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 diff --git a/plinth/modules/names/templates/names.html b/plinth/modules/names/templates/names.html index 126e18617..c3ea506d4 100644 --- a/plinth/modules/names/templates/names.html +++ b/plinth/modules/names/templates/names.html @@ -11,9 +11,9 @@ - - - + + + diff --git a/plinth/modules/performance/__init__.py b/plinth/modules/performance/__init__.py index 61c813e8c..0c67a98bb 100644 --- a/plinth/modules/performance/__init__.py +++ b/plinth/modules/performance/__init__.py @@ -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 diff --git a/plinth/modules/radicale/forms.py b/plinth/modules/radicale/forms.py index 6536b9e92..0ce96e0f2 100644 --- a/plinth/modules/radicale/forms.py +++ b/plinth/modules/radicale/forms.py @@ -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()) diff --git a/plinth/modules/users/forms.py b/plinth/modules/users/forms.py index 91c469fff..bebb77b74 100644 --- a/plinth/modules/users/forms.py +++ b/plinth/modules/users/forms.py @@ -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.'))
TypeDomain NameServices{% trans "Type" %}{% trans "Domain Name" %}{% trans "Services" %}