Allow users to select UI language at login or from Preferences rather than unpredictable behaviour from browsers. Fixes #2190

This commit is contained in:
Khushboo Vashi
2017-03-24 14:20:10 +00:00
committed by Dave Page
parent 6cb9ece6fd
commit 0eda6033df
11 changed files with 171 additions and 30 deletions

View File

@@ -126,8 +126,9 @@ class _Preference(object):
current_app.logger.exeception(e)
return self.default
if self._type == 'options':
if res.value in self.options:
return res.value
for opt in self.options:
if 'value' in opt and opt['value'] == res.value:
return res.value
return self.default
if self._type == 'text':
if res.value == '':
@@ -184,7 +185,12 @@ class _Preference(object):
current_app.logger.exeception(e)
return False, gettext("Invalid value for a datetime option.")
elif self._type == 'options':
if value not in self.options:
has_value = False
for opt in self.options:
if 'value' in opt and opt['value'] == value:
has_value = True
if not has_value:
return False, gettext("Invalid value for an options option.")
pref = UserPrefTable.query.filter_by(