From 4503ac07beed8e8694cb6243ae52ccd97d14104d Mon Sep 17 00:00:00 2001 From: James Elliott Date: Fri, 8 Apr 2022 14:53:46 +1000 Subject: [PATCH] fix(web): lowercase locales are not consistent with localization platforms (#3141) This fixes an issue with localization platforms and the docs regarding localization, and the forcing locale names to lowercase. --- docs/configuration/server.md | 6 +++--- internal/server/handlers.go | 2 +- web/src/i18n/index.ts | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/configuration/server.md b/docs/configuration/server.md index 3a705a425..adf33dfb6 100644 --- a/docs/configuration/server.md +++ b/docs/configuration/server.md @@ -263,8 +263,8 @@ Authelia will automatically resize the logo to an appropriate size to present in The locales folder holds folders of internationalization locales. This folder can be utilized to override these locales. They are the names of locales that are returned by the `navigator.langauge` ECMAScript command. These are generally -those in the [RFC5646 / BCP47 Format](https://datatracker.ietf.org/doc/html/rfc5646) except the name normalized to -lowercase for consistency ease; for example the `en-US` locale should be in the directory `en-us`. +those in the [RFC5646 / BCP47 Format](https://datatracker.ietf.org/doc/html/rfc5646) specifically the language codes +from [Crowdin](https://support.crowdin.com/api/language-codes/). Each directory has json files which you can explore the format of in the [internal/server/locales](https://github.com/authelia/authelia/tree/master/internal/server/locales) directory on @@ -275,7 +275,7 @@ of current namespaces are below: |:---------:|:-------------------:| | portal | Portal translations | -A full example for the `en-US` locale for the portal namespace is `locales/en-us/portal.json`. +A full example for the `en-US` locale for the portal namespace is `locales/en-US/portal.json`. Languages in browsers are supported in two forms. In their language only form such as `en` for English, and in their variant form such as `en-AU` for English (Australian). If a user has the browser language `en-AU` we automatically load diff --git a/internal/server/handlers.go b/internal/server/handlers.go index 6a89445e6..aea535e91 100644 --- a/internal/server/handlers.go +++ b/internal/server/handlers.go @@ -121,7 +121,7 @@ func getHandler(config schema.Configuration, providers middlewares.Providers) fa r.GET("/static/{filepath:*}", handlerPublicHTML) // Locales. - r.GET("/locales/{language:[a-z]{1,3}}-{variant:[a-z0-9-]+}/{namespace:[a-z]+}.json", middlewares.AssetOverrideMiddleware(config.Server.AssetPath, 0, handlerLocales)) + r.GET("/locales/{language:[a-z]{1,3}}-{variant:[a-zA-Z0-9-]+}/{namespace:[a-z]+}.json", middlewares.AssetOverrideMiddleware(config.Server.AssetPath, 0, handlerLocales)) r.GET("/locales/{language:[a-z]{1,3}}/{namespace:[a-z]+}.json", middlewares.AssetOverrideMiddleware(config.Server.AssetPath, 0, handlerLocales)) // Swagger. diff --git a/web/src/i18n/index.ts b/web/src/i18n/index.ts index 035f30559..1e23cfc61 100644 --- a/web/src/i18n/index.ts +++ b/web/src/i18n/index.ts @@ -21,7 +21,7 @@ i18n.use(Backend) }, load: "all", supportedLngs: ["en", "es", "de"], - lowerCaseLng: true, + lowerCaseLng: false, nonExplicitSupportedLngs: true, interpolation: { escapeValue: false,