Update Beans.java

This commit is contained in:
Anthony Stirling 2023-06-12 17:31:42 +01:00 committed by GitHub
parent c9b0d01250
commit e5990dba81
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -39,12 +39,19 @@ public class Beans implements WebMvcConfigurer {
Locale tempLocale = Locale.forLanguageTag(appLocaleEnv); Locale tempLocale = Locale.forLanguageTag(appLocaleEnv);
String tempLanguageTag = tempLocale.toLanguageTag(); String tempLanguageTag = tempLocale.toLanguageTag();
if (appLocaleEnv.equalsIgnoreCase(tempLanguageTag)) {
defaultLocale = tempLocale;
} else {
tempLocale = Locale.forLanguageTag(appLocaleEnv.replace("_","-"));
tempLanguageTag = tempLocale.toLanguageTag();
if (appLocaleEnv.equalsIgnoreCase(tempLanguageTag)) { if (appLocaleEnv.equalsIgnoreCase(tempLanguageTag)) {
defaultLocale = tempLocale; defaultLocale = tempLocale;
} else { } else {
System.err.println("Invalid APP_LOCALE environment variable value. Falling back to default Locale.UK."); System.err.println("Invalid APP_LOCALE environment variable value. Falling back to default Locale.UK.");
} }
} }
}
slr.setDefaultLocale(defaultLocale); slr.setDefaultLocale(defaultLocale);
return slr; return slr;