From 1c75c14a6a162e7064e09e9af098bccca1372a38 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 18 Jul 2021 19:57:08 +0100 Subject: [PATCH] Sort languages list --- utils.py | 2 +- webapp_profile.py | 16 +++++++++++----- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/utils.py b/utils.py index 9d2dabce9..602bf5417 100644 --- a/utils.py +++ b/utils.py @@ -2579,7 +2579,7 @@ def getActorLanguagesList(actorJson: {}) -> []: if not isinstance(propertyValue['value'], list): continue if propertyValue['type'] != 'PropertyValue': - continue + continue return propertyValue['value'] return [] diff --git a/webapp_profile.py b/webapp_profile.py index f95827046..3572decfd 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -1779,7 +1779,7 @@ def _htmlEditProfileOptions(manuallyApprovesFollowers: str, def _getSupportedLanguages(baseDir: str) -> str: """Returns a list of supported languages """ - languagesStr = '' + langList = [] for subdir, dirs, files in os.walk(baseDir + '/translations'): for f in files: if not f.endswith('.json'): @@ -1787,11 +1787,17 @@ def _getSupportedLanguages(baseDir: str) -> str: langStr = f.split('.')[0] if len(langStr) != 2: continue - if languagesStr: - languagesStr += ' / ' + langStr - else: - languagesStr = langStr + langList.append(langStr) break + if not langList: + return '' + langList.sort() + languagesStr = '' + for lang in langList: + if languagesStr: + languagesStr += ' / ' + lang + else: + languagesStr = lang return languagesStr