diff --git a/frontend/public/locales/en/BranchSelect.json b/backend/locales/en/BranchSelect.json similarity index 100% rename from frontend/public/locales/en/BranchSelect.json rename to backend/locales/en/BranchSelect.json diff --git a/frontend/public/locales/en/Common.json b/backend/locales/en/Common.json similarity index 100% rename from frontend/public/locales/en/Common.json rename to backend/locales/en/Common.json diff --git a/frontend/public/locales/en/DeveloperIndex.json b/backend/locales/en/DeveloperIndex.json similarity index 100% rename from frontend/public/locales/en/DeveloperIndex.json rename to backend/locales/en/DeveloperIndex.json diff --git a/frontend/public/locales/en/PluginCard.json b/backend/locales/en/PluginCard.json similarity index 100% rename from frontend/public/locales/en/PluginCard.json rename to backend/locales/en/PluginCard.json diff --git a/frontend/public/locales/en/PluginInstallModal.json b/backend/locales/en/PluginInstallModal.json similarity index 100% rename from frontend/public/locales/en/PluginInstallModal.json rename to backend/locales/en/PluginInstallModal.json diff --git a/frontend/public/locales/en/PluginListIndex.json b/backend/locales/en/PluginListIndex.json similarity index 100% rename from frontend/public/locales/en/PluginListIndex.json rename to backend/locales/en/PluginListIndex.json diff --git a/frontend/public/locales/en/RemoteDebugging.json b/backend/locales/en/RemoteDebugging.json similarity index 100% rename from frontend/public/locales/en/RemoteDebugging.json rename to backend/locales/en/RemoteDebugging.json diff --git a/frontend/public/locales/en/SettingsGeneralIndex.json b/backend/locales/en/SettingsGeneralIndex.json similarity index 100% rename from frontend/public/locales/en/SettingsGeneralIndex.json rename to backend/locales/en/SettingsGeneralIndex.json diff --git a/frontend/public/locales/en/SettingsIndex.json b/backend/locales/en/SettingsIndex.json similarity index 100% rename from frontend/public/locales/en/SettingsIndex.json rename to backend/locales/en/SettingsIndex.json diff --git a/frontend/public/locales/en/Store.json b/backend/locales/en/Store.json similarity index 100% rename from frontend/public/locales/en/Store.json rename to backend/locales/en/Store.json diff --git a/frontend/public/locales/en/StoreSelect.json b/backend/locales/en/StoreSelect.json similarity index 100% rename from frontend/public/locales/en/StoreSelect.json rename to backend/locales/en/StoreSelect.json diff --git a/frontend/public/locales/en/Updater.json b/backend/locales/en/Updater.json similarity index 100% rename from frontend/public/locales/en/Updater.json rename to backend/locales/en/Updater.json diff --git a/frontend/public/locales/en/plugin-loader.json b/backend/locales/en/plugin-loader.json similarity index 100% rename from frontend/public/locales/en/plugin-loader.json rename to backend/locales/en/plugin-loader.json diff --git a/frontend/public/locales/it/BranchSelect.json b/backend/locales/it/BranchSelect.json similarity index 100% rename from frontend/public/locales/it/BranchSelect.json rename to backend/locales/it/BranchSelect.json diff --git a/frontend/public/locales/it/Common.json b/backend/locales/it/Common.json similarity index 100% rename from frontend/public/locales/it/Common.json rename to backend/locales/it/Common.json diff --git a/frontend/public/locales/it/DeveloperIndex.json b/backend/locales/it/DeveloperIndex.json similarity index 100% rename from frontend/public/locales/it/DeveloperIndex.json rename to backend/locales/it/DeveloperIndex.json diff --git a/frontend/public/locales/it/PluginCard.json b/backend/locales/it/PluginCard.json similarity index 100% rename from frontend/public/locales/it/PluginCard.json rename to backend/locales/it/PluginCard.json diff --git a/frontend/public/locales/it/PluginInstallModal.json b/backend/locales/it/PluginInstallModal.json similarity index 100% rename from frontend/public/locales/it/PluginInstallModal.json rename to backend/locales/it/PluginInstallModal.json diff --git a/frontend/public/locales/it/PluginListIndex.json b/backend/locales/it/PluginListIndex.json similarity index 100% rename from frontend/public/locales/it/PluginListIndex.json rename to backend/locales/it/PluginListIndex.json diff --git a/frontend/public/locales/it/RemoteDebugging.json b/backend/locales/it/RemoteDebugging.json similarity index 100% rename from frontend/public/locales/it/RemoteDebugging.json rename to backend/locales/it/RemoteDebugging.json diff --git a/frontend/public/locales/it/SettingsGeneralIndex.json b/backend/locales/it/SettingsGeneralIndex.json similarity index 100% rename from frontend/public/locales/it/SettingsGeneralIndex.json rename to backend/locales/it/SettingsGeneralIndex.json diff --git a/frontend/public/locales/it/SettingsIndex.json b/backend/locales/it/SettingsIndex.json similarity index 100% rename from frontend/public/locales/it/SettingsIndex.json rename to backend/locales/it/SettingsIndex.json diff --git a/frontend/public/locales/it/Store.json b/backend/locales/it/Store.json similarity index 100% rename from frontend/public/locales/it/Store.json rename to backend/locales/it/Store.json diff --git a/frontend/public/locales/it/StoreSelect.json b/backend/locales/it/StoreSelect.json similarity index 100% rename from frontend/public/locales/it/StoreSelect.json rename to backend/locales/it/StoreSelect.json diff --git a/frontend/public/locales/it/Updater.json b/backend/locales/it/Updater.json similarity index 100% rename from frontend/public/locales/it/Updater.json rename to backend/locales/it/Updater.json diff --git a/frontend/public/locales/it/plugin-loader.json b/backend/locales/it/plugin-loader.json similarity index 100% rename from frontend/public/locales/it/plugin-loader.json rename to backend/locales/it/plugin-loader.json diff --git a/backend/main.py b/backend/main.py index a2ac008a..7c612bfa 100644 --- a/backend/main.py +++ b/backend/main.py @@ -93,6 +93,7 @@ class PluginManager: for route in list(self.web_app.router.routes()): self.cors.add(route) self.web_app.add_routes([static("/static", path.join(path.dirname(__file__), 'static'))]) + self.web_app.add_routes([static("/locales", path.join(path.dirname(__file__), 'locales'))]) self.web_app.add_routes([static("/legacy", path.join(path.dirname(__file__), 'legacy'))]) def exception_handler(self, loop, context): @@ -101,6 +102,7 @@ class PluginManager: loop.default_exception_handler(context) async def get_auth_token(self, request): + return Response(text=get_csrf_token()) async def load_plugins(self): diff --git a/frontend/src/i18n.ts b/frontend/src/i18n.ts index 7258bae4..9bf417f9 100644 --- a/frontend/src/i18n.ts +++ b/frontend/src/i18n.ts @@ -6,6 +6,33 @@ i18next .use(Backend) .use(initReactI18next) .init({ + backend:{ + // path where resources get loaded from, or a function + // returning a path: + // function(lngs, namespaces) { return customPath; } + // the returned path will interpolate lng, ns if provided like giving a static path + // the function might return a promise + // returning falsy will abort the download + // + // If allowMultiLoading is false, lngs and namespaces will have only one element each, + // If allowMultiLoading is true, lngs and namespaces can have multiple elements + loadPath: 'http://127.0.0.1:1337/locales/{{lng}}/{{ns}}.json', + + // your backend server supports multiloading + // /locales/resources.json?lng=de+en&ns=ns1+ns2 + // Adapter is needed to enable MultiLoading https://github.com/i18next/i18next-multiload-backend-adapter + // Returned JSON structure in this case is + // { + // lang : { + // namespaceA: {}, + // namespaceB: {}, + // ...etc + // } + // } + allowMultiLoading: false, // set loadPath: '/locales/resources.json?lng={{lng}}&ns={{ns}}' to adapt to multiLoading + + reloadInterval: false // can be used to reload resources in a specific interval (useful in server environments) + }, debug: true, fallbackLng: 'en', fallbackNS: 'Common', @@ -13,6 +40,7 @@ i18next interpolation: { escapeValue: false, }, + load: 'languageOnly' }); export default i18next;