As asked in #11, then my question is pretty much the same, I use Nunjucks to have multiple themes on the same instance, that be, a frontend theme and a backend theme.
The language files should be a part of the theme directory and not something you store globally outside the theme itself.
As per now, the theme is defined in a middleware and set in a state, and used by all other elements.
app.use( function( ctx, next ) {
ctx.state.theme = 'default';
await next();
} );
How would I go about accessing ctx.state.theme when initializing koa-i18n inside the middleware, pseudo example code
app.use( i18n( app, {
directory: `./themes/${ctx.state.theme}/languages`,
} ) );
As asked in #11, then my question is pretty much the same, I use Nunjucks to have multiple themes on the same instance, that be, a frontend theme and a backend theme.
The language files should be a part of the theme directory and not something you store globally outside the theme itself.
As per now, the theme is defined in a middleware and set in a state, and used by all other elements.
How would I go about accessing
ctx.state.themewhen initializingkoa-i18ninside the middleware, pseudo example code