From c3167dac64bccf8a6d5a5bde3baaffbb98cde063 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Fri, 16 Feb 2018 15:01:14 +0530 Subject: [PATCH] config: Remove language selection from config page Signed-off-by: Sunil Mohan Adapa Reviewed-by: James Valleroy --- plinth/modules/config/forms.py | 19 ------------------- plinth/modules/config/views.py | 24 ------------------------ 2 files changed, 43 deletions(-) diff --git a/plinth/modules/config/forms.py b/plinth/modules/config/forms.py index fcca6ebc0..8a6a9b232 100644 --- a/plinth/modules/config/forms.py +++ b/plinth/modules/config/forms.py @@ -93,22 +93,3 @@ class ConfigurationForm(forms.Form): r'^[a-zA-Z0-9]([-a-zA-Z0-9.]{,251}[a-zA-Z0-9])?$', ugettext_lazy('Invalid domain name')), domain_label_validator]) - - language = forms.ChoiceField( - label=ugettext_lazy('Language'), - help_text=ugettext_lazy( - 'Language for this web administration interface'), - required=False) - - def __init__(self, *args, **kwargs): - """Set limited language choices.""" - super().__init__(*args, **kwargs) - languages = [] - for language_code, language_name in settings.LANGUAGES: - locale_code = translation.to_locale(language_code) - plinth_dir = os.path.dirname(plinth.__file__) - if language_code == 'en' or os.path.exists( - os.path.join(plinth_dir, 'locale', locale_code)): - languages.append((language_code, language_name)) - - self.fields['language'].choices = languages diff --git a/plinth/modules/config/views.py b/plinth/modules/config/views.py index 9237408ff..40fb9abab 100644 --- a/plinth/modules/config/views.py +++ b/plinth/modules/config/views.py @@ -36,17 +36,6 @@ from .forms import ConfigurationForm LOGGER = logging.getLogger(__name__) -def get_language(request): - """Return the current language setting""" - # TODO: Store the language per user in kvstore, - # taking care of setting language on login, and adapting kvstore when - # renaming/deleting users - - # The information from the session is more accurate but not always present - return request.session.get(translation.LANGUAGE_SESSION_KEY, - request.LANGUAGE_CODE) - - def index(request): """Serve the configuration form""" status = get_status(request) @@ -73,7 +62,6 @@ def get_status(request): return { 'hostname': config.get_hostname(), 'domainname': config.get_domainname(), - 'language': get_language(request) } @@ -99,18 +87,6 @@ def _apply_changes(request, old_status, new_status): else: messages.success(request, _('Domain name set')) - if old_status['language'] != new_status['language']: - language = new_status['language'] - try: - translation.activate(language) - request.session[translation.LANGUAGE_SESSION_KEY] = language - except Exception as exception: - messages.error(request, - _('Error setting language: {exception}') - .format(exception=exception)) - else: - messages.success(request, _('Language changed')) - def set_hostname(hostname): """Sets machine hostname to hostname"""