From 4ef2e20b4fe1ea42cfd1bac1f192fd60e25a095d Mon Sep 17 00:00:00 2001 From: nucleogenic Date: Sat, 10 Sep 2022 02:58:47 +0100 Subject: [PATCH] Update get_supported_locales to return a JSON serializable result --- python/web/src/web.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/python/web/src/web.py b/python/web/src/web.py index 9c567763..288113fb 100644 --- a/python/web/src/web.py +++ b/python/web/src/web.py @@ -89,10 +89,12 @@ def get_supported_locales(): """ Returns a list of Locale objects that the Web Interfaces supports """ - locales = BABEL.list_translations() - locales.append(Locale("en")) - sorted_locales = sorted(locales, key=lambda x: x.language) - return sorted_locales + locales = [ + {"language": x.language, "display_name": x.display_name} + for x in [*BABEL.list_translations(), Locale("en")] + ] + + return sorted(locales, key=lambda x: x["language"]) # pylint: disable=too-many-locals