Index: lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java =================================================================== diff -u -r38369b1b4eafec27b67fb77663984cde3de776d9 -ra1046dbdfb10ad1f7a61b8d50acbff46ac7c96ab --- lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java (.../ImportService.java) (revision 38369b1b4eafec27b67fb77663984cde3de776d9) +++ lams_admin/src/java/org/lamsfoundation/lams/admin/service/ImportService.java (.../ImportService.java) (revision a1046dbdfb10ad1f7a61b8d50acbff46ac7c96ab) @@ -603,7 +603,7 @@ user.setPostcode(parseStringCell(row.getCell(ImportService.POSTCODE))); String country = parseStringCell(row.getCell(ImportService.COUNTRY)); if (StringUtils.isBlank(country)) { - country = LanguageUtil.DEFAULT_COUNTRY; + country = LanguageUtil.getDefaultCountry(); } user.setCountry(country); user.setDayPhone(parseStringCell(row.getCell(ImportService.DAY_PHONE))); Index: lams_common/src/java/org/lamsfoundation/lams/signup/service/SignupService.java =================================================================== diff -u -rfebc5ec394566f98439ce776a0be320b34310b0a -ra1046dbdfb10ad1f7a61b8d50acbff46ac7c96ab --- lams_common/src/java/org/lamsfoundation/lams/signup/service/SignupService.java (.../SignupService.java) (revision febc5ec394566f98439ce776a0be320b34310b0a) +++ lams_common/src/java/org/lamsfoundation/lams/signup/service/SignupService.java (.../SignupService.java) (revision a1046dbdfb10ad1f7a61b8d50acbff46ac7c96ab) @@ -163,7 +163,7 @@ private SupportedLocale getDefaultLocale() { String localeName = Configuration.get(ConfigurationKeys.SERVER_LANGUAGE); String langIsoCode = LanguageUtil.DEFAULT_LANGUAGE; - String countryIsoCode = LanguageUtil.DEFAULT_COUNTRY; + String countryIsoCode = LanguageUtil.getDefaultCountry(); if (StringUtils.isNotBlank(localeName) && localeName.length() > 2) { langIsoCode = localeName.substring(0, 2); countryIsoCode = localeName.substring(3); Index: lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java =================================================================== diff -u -r7e808255a63e7ad7345100840771ee11ee8d8a47 -ra1046dbdfb10ad1f7a61b8d50acbff46ac7c96ab --- lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java (.../ConfigurationKeys.java) (revision 7e808255a63e7ad7345100840771ee11ee8d8a47) +++ lams_common/src/java/org/lamsfoundation/lams/util/ConfigurationKeys.java (.../ConfigurationKeys.java) (revision a1046dbdfb10ad1f7a61b8d50acbff46ac7c96ab) @@ -84,6 +84,11 @@ /** Default locale for the server. Originally en_AU */ public static String SERVER_LANGUAGE = "ServerLanguage"; + + /** + * Default country for the server. Originally AU + */ + public static String SERVER_COUNTRY = "ServerCountry"; /** * Direction (left to right, right to left) for writing on HTML pages. Originally LTR Index: lams_common/src/java/org/lamsfoundation/lams/util/LanguageUtil.java =================================================================== diff -u -r6af1dca405b378528e883a2853703bbf75e7d68c -ra1046dbdfb10ad1f7a61b8d50acbff46ac7c96ab --- lams_common/src/java/org/lamsfoundation/lams/util/LanguageUtil.java (.../LanguageUtil.java) (revision 6af1dca405b378528e883a2853703bbf75e7d68c) +++ lams_common/src/java/org/lamsfoundation/lams/util/LanguageUtil.java (.../LanguageUtil.java) (revision a1046dbdfb10ad1f7a61b8d50acbff46ac7c96ab) @@ -81,7 +81,7 @@ languageIsoCode = LanguageUtil.DEFAULT_LANGUAGE; } if (countryIsoCode == null) { - languageIsoCode = LanguageUtil.DEFAULT_COUNTRY; + languageIsoCode = LanguageUtil.getDefaultCountry(); } return new String[] { languageIsoCode, countryIsoCode }; @@ -116,36 +116,43 @@ public static SupportedLocale getDefaultLocale() { String localeName = Configuration.get(ConfigurationKeys.SERVER_LANGUAGE); String langIsoCode = LanguageUtil.DEFAULT_LANGUAGE; - String countryIsoCode = LanguageUtil.DEFAULT_COUNTRY; + // try to use the server's country first + String countryIsoCode = LanguageUtil.getDefaultCountry(); if (StringUtils.isNotBlank(localeName) && (localeName.length() > 2)) { langIsoCode = localeName.substring(0, 2); countryIsoCode = localeName.substring(3); } SupportedLocale locale = null; - locale = getSupportedLocaleOrNull(langIsoCode, countryIsoCode); + locale = LanguageUtil.getSupportedLocaleOrNull(langIsoCode, countryIsoCode); if (locale == null) { - locale = getSupportedLocaleOrNull(LanguageUtil.DEFAULT_LANGUAGE, LanguageUtil.DEFAULT_COUNTRY); + // if default language and server do not yield result, default to en_AU + locale = LanguageUtil.getSupportedLocaleOrNull(LanguageUtil.DEFAULT_LANGUAGE, LanguageUtil.DEFAULT_COUNTRY); } return locale; } + public static String getDefaultCountry() { + String serverCountry = Configuration.get(ConfigurationKeys.SERVER_COUNTRY); + return StringUtils.isBlank(serverCountry) ? LanguageUtil.DEFAULT_COUNTRY : serverCountry; + } + /** * Searches for a locale based on language, then country, matching the single input string. Otherwise returns server * default locale. */ public static SupportedLocale getSupportedLocale(String input) { - List list = getService().findByProperty(SupportedLocale.class, "languageIsoCode", input); + List list = LanguageUtil.getService().findByProperty(SupportedLocale.class, "languageIsoCode", input); if ((list != null) && (list.size() > 0)) { return (SupportedLocale) list.get(0); } else { - list = getService().findByProperty(SupportedLocale.class, "countryIsoCode", input); + list = LanguageUtil.getService().findByProperty(SupportedLocale.class, "countryIsoCode", input); if ((list != null) && (list.size() > 0)) { return (SupportedLocale) list.get(0); } } - return getDefaultLocale(); + return LanguageUtil.getDefaultLocale(); } /** @@ -154,9 +161,9 @@ public static SupportedLocale getSupportedLocale(String langIsoCode, String countryIsoCode) { SupportedLocale locale = null; - locale = getSupportedLocaleOrNull(langIsoCode, countryIsoCode); + locale = LanguageUtil.getSupportedLocaleOrNull(langIsoCode, countryIsoCode); if (locale == null) { - locale = getDefaultLocale(); + locale = LanguageUtil.getDefaultLocale(); } return locale; @@ -180,7 +187,7 @@ return null; } - List list = getService().findByProperties(SupportedLocale.class, properties); + List list = LanguageUtil.getService().findByProperties(SupportedLocale.class, properties); if ((list != null) && (list.size() > 0)) { Collections.sort(list); locale = (SupportedLocale) list.get(0); @@ -189,25 +196,25 @@ } return locale; } - + /** * Get list of all available country names sorted alphabetically. - * + * * @parama enforceUsingDefaultLocale in some rare cases (like with SignupAction) it's useful to enforce using LAMS * server's default locale, instead of the system default one */ public static Map getCountryCodes(boolean enforceUsingDefaultLocale) { - getMessageService(); + LanguageUtil.getMessageService(); SupportedLocale lamsDefaultLocale = enforceUsingDefaultLocale ? LanguageUtil.getDefaultLocale() : null; - + Map countryCodesMap = new HashMap(); for (String countryCode : CommonConstants.COUNTRY_CODES) { String countryName = enforceUsingDefaultLocale ? messageService.getMessage("country." + countryCode, lamsDefaultLocale) : messageService.getMessage("country." + countryCode); countryCodesMap.put(countryCode, countryName); } - + //sort alphabetically return countryCodesMap.entrySet().stream().sorted(Map.Entry.comparingByValue(Comparator.naturalOrder())) .collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (oldValue, newValue) -> oldValue, @@ -222,7 +229,7 @@ } return service; } - + private static MessageService getMessageService() { if (messageService == null) { WebApplicationContext ctx = WebApplicationContextUtils