Browse Source

fixed the lang.sort fix

master
age 14 years ago
parent
commit
bacd63be6c
  1. 12
      src/cryptobox/core/settings.py
  2. 3
      src/cryptobox/web/dataset.py
  3. 3
      src/cryptobox/web/sites.py

12
src/cryptobox/core/settings.py

@ -583,7 +583,7 @@ Details = string(min=1, default="/var/log/cryptobox-server/cryptobox.log")
[WebSettings]
Stylesheet = string(min=1)
Languages = list(min=1,default=list("en"))
Languages = listOfLanguages(default="en")
[Programs]
cryptsetup = fileExecutable(default="/sbin/cryptsetup")
@ -624,6 +624,7 @@ class CryptoBoxSettingsValidator(validate.Validator):
self.functions["fileExecutable"] = self.check_file_executable
self.functions["fileWriteable"] = self.check_file_writeable
self.functions["listOfExistingDirectories"] = self.check_existing_directories
self.functions["listOfLanguages"] = self.list_languages
def check_directory_exists(self, value):
@ -682,6 +683,15 @@ class CryptoBoxSettingsValidator(validate.Validator):
result.append(dir_path)
return result
def list_languages(self, langs):
"""Return languages as a list.
"""
if not langs:
raise validate.VdtValueError("no language specified")
if not isinstance(langs, list):
langs = [langs]
return langs
class MiscConfigFile:
"""all other config files (e.g. a ssl certificate) to be stored"""

3
src/cryptobox/web/dataset.py

@ -57,8 +57,7 @@ class WebInterfaceDataset(dict):
for key in self.keys():
if key.startswith("Data.Languages."):
del self[key]
langs = []
langs.append(self.cbox.prefs["WebSettings"]["Languages"][:])
langs = self.cbox.prefs["WebSettings"]["Languages"][:]
langs.sort()
for (index, lang) in enumerate(langs):
try:

3
src/cryptobox/web/sites.py

@ -458,8 +458,7 @@ class WebInterfaceSites:
3. languages defined in the config file
"""
## start with the configured language order
lang_order = []
lang_order.append(self.cbox.prefs["WebSettings"]["Languages"][:])
lang_order = self.cbox.prefs["WebSettings"]["Languages"][:]
self.cbox.log.debug(
"updating language preferences (default: %s)" % str(lang_order))
## put the preferred browser language in front

Loading…
Cancel
Save