From 51afb63e25b489249cadf1e2006d1b1fe41b59b8 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 11 Aug 2024 07:36:09 +0300 Subject: [PATCH] server: Add endpoint to get list of locales --- src/routes/api/options.ts | 17 ++++++++++++++++- src/routes/routes.ts | 1 + 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/src/routes/api/options.ts b/src/routes/api/options.ts index 2113746ba..d7ea7520a 100644 --- a/src/routes/api/options.ts +++ b/src/routes/api/options.ts @@ -129,6 +129,20 @@ function getUserThemes() { return ret; } +function getSupportedLocales() { + // TODO: Currently hardcoded, needs to read the lits of available languages. + return [ + { + "id": "en", + "name": "English" + }, + { + "id": "cn", + "name": "Chinese" + } + ]; +} + function isAllowed(name: string) { return ALLOWED_OPTIONS.has(name) || name.startsWith("keyboardShortcuts") @@ -140,5 +154,6 @@ export default { getOptions, updateOption, updateOptions, - getUserThemes + getUserThemes, + getSupportedLocales }; diff --git a/src/routes/routes.ts b/src/routes/routes.ts index 5a3e181c5..e808c1e0d 100644 --- a/src/routes/routes.ts +++ b/src/routes/routes.ts @@ -217,6 +217,7 @@ function register(app: express.Application) { apiRoute(PUT, '/api/options/:name/:value*', optionsApiRoute.updateOption); apiRoute(PUT, '/api/options', optionsApiRoute.updateOptions); apiRoute(GET, '/api/options/user-themes', optionsApiRoute.getUserThemes); + apiRoute(GET, '/api/options/locales', optionsApiRoute.getSupportedLocales); apiRoute(PST, '/api/password/change', passwordApiRoute.changePassword); apiRoute(PST, '/api/password/reset', passwordApiRoute.resetPassword);