mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-03-11 09:04:54 +00:00
config: Remove language selection from config page
Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
parent
6090d5c37d
commit
c3167dac64
@ -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
|
||||
|
||||
@ -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"""
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user