Setu-TS
    Preparing search index...

    Function localeMiddleware

    • Creates the locale resolution middleware.

      Register it globally (the plugin does, at priority 45) or per route group when the plugin's own registration is disabled. On every path it does not exclude it:

      1. appends Vary: Accept-Language — plus Cookie while the cookie source is enabled — before next(), unconditionally, because the response varies by those headers whether or not they won this time;
      2. writes the resolved tag through replaceLocale;
      3. after next() resolves, sets Content-Language from the FINAL ctx.request.locale, unless the response already carries one or the final value is not a supported tag. A rejection from next() propagates with no Content-Language written.

      Parameters

      Returns MiddlewareFunction

      The middleware

      If supportedLocales is invalid

      app.middleware.add(localeMiddleware({ supportedLocales: ['en', 'de'] }), { priority: 45 });
      

      0.9.0