Initial backend hosting implementation

This commit is contained in:
Marco Rodolfi
2023-01-23 18:18:46 +01:00
parent 8da0395917
commit 5f455a01b7
28 changed files with 30 additions and 0 deletions
+2
View File
@@ -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):
+28
View File
@@ -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;