LANG-1312: LocaleUtils#toLocale does not support language followed by UN M.49 numeric-3 area code (closes #239)
This commit is contained in:
parent
a6443e146f
commit
4bd982d1a1
|
@ -76,6 +76,7 @@ The <action> type attribute can be add,update,fix,remove.
|
|||
<action issue="LANG-1297" type="update" dev="ggregory">Add SystemUtils.getHostName() API.</action>
|
||||
<action issue="LANG-1301" type="update" dev="pschumacher" due-to="Karl Heinz Marbaise">Moving apache-rat-plugin configuration into pluginManagement</action>
|
||||
<action issue="LANG-1311" type="fix" dev="pschumacher" due-to="Aaron Digulla">TypeUtils.toString() doesn't handle primitive and Object arrays correctly</action>
|
||||
<action issue="LANG-1312" type="fix" dev="pschumacher">LocaleUtils#toLocale does not support language followed by UN M.49 numeric-3 area code</action>
|
||||
</release>
|
||||
|
||||
<release version="3.5" date="2016-10-13" description="New features including Java 9 detection">
|
||||
|
|
|
@ -67,6 +67,7 @@ public class LocaleUtils {
|
|||
* LocaleUtils.toLocale("") = new Locale("", "")
|
||||
* LocaleUtils.toLocale("en") = new Locale("en", "")
|
||||
* LocaleUtils.toLocale("en_GB") = new Locale("en", "GB")
|
||||
* LocaleUtils.toLocale("en_001") = new Locale("en", "001")
|
||||
* LocaleUtils.toLocale("en_GB_xxx") = new Locale("en", "GB", "xxx") (#)
|
||||
* </pre>
|
||||
*
|
||||
|
@ -134,7 +135,8 @@ public class LocaleUtils {
|
|||
case 1:
|
||||
if (StringUtils.isAllLowerCase(split[0]) &&
|
||||
(split[0].length() == 2 || split[0].length() == 3) &&
|
||||
split[1].length() == 2 && StringUtils.isAllUpperCase(split[1])) {
|
||||
(split[1].length() == 2 && StringUtils.isAllUpperCase(split[1])) ||
|
||||
(split[1].length() == 3 && StringUtils.isNumeric(split[1]))) {
|
||||
return new Locale(split[0], split[1]);
|
||||
}
|
||||
throw new IllegalArgumentException("Invalid locale format: " + str);
|
||||
|
|
|
@ -505,6 +505,13 @@ public class LocaleUtilsTest {
|
|||
assertValidToLocale("fr__POSIX", "fr", "", "POSIX");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testLanguageAndUNM49Numeric3AreaCodeLang1312() {
|
||||
assertValidToLocale("en_001", "en", "001");
|
||||
assertValidToLocale("en_150", "en", "150");
|
||||
assertValidToLocale("ar_001", "ar", "001");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests #LANG-865, strings starting with an underscore.
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue