Add support for more BCP combinations

- region, variant, script & language combined
 - 2 char language, 2 char region
 - 2 char lang, 4 char script, 3 char variant
This commit is contained in:
Connor Tumbleson 2015-02-21 16:48:48 -06:00
parent da347b22ba
commit dc02abcf51
5 changed files with 33 additions and 7 deletions

View File

@ -377,7 +377,9 @@ public class ResConfigFlags {
// denies values-xxx, anything else
if (language[0] != '\00' && localeScript.length == 0 && localeVariant.length == 0 &&
(region.length != 3 && language.length != 3) ||
(language.length == 3 && region.length == 2 && region[0] != '\00')) {
(language.length == 3 && region.length == 2 && region[0] != '\00' &&
localeScript.length == 0 && localeVariant.length == 0)) {
sb.append("-").append(language);
if (region[0] != '\00') {
sb.append("-r").append(region);
@ -390,16 +392,13 @@ public class ResConfigFlags {
if (language[0] != '\00') {
sb.append(language);
}
if (localeScript.length == 4 && region.length == 2) {
sb.append("+").append(localeScript).append("+").append(region);
if (localeScript.length == 4) {
sb.append("+").append(localeScript);
}
if (region.length == 3) {
if ((region.length == 2 || region.length == 3) && region[0] != '\00') {
sb.append("+").append(region);
}
if (localeVariant.length >= 5) {
if (region.length == 2) {
sb.append("+").append(region);
}
sb.append("+").append(toUpper(localeVariant));
}
}

View File

@ -202,11 +202,26 @@ public class BuildAndDecodeTest {
compareValuesFiles("values-b+ast/strings.xml");
}
@Test
public void twoLetterLangBcp47Test() throws BrutException, IOException {
compareValuesFiles("values-en-rUS/strings.xml");
}
@Test
public void variantBcp47Test() throws BrutException, IOException {
compareValuesFiles("values-b+en+US+POSIX/strings.xml");
}
@Test
public void fourpartBcp47Test() throws BrutException, IOException {
compareValuesFiles("values-b+ast+Latn+IT+AREVELA/strings.xml");
}
@Test
public void RegionLocaleBcp47Test() throws BrutException, IOException {
compareValuesFiles("values-b+en+Latn+419/strings.xml");
}
@Test
public void numericalRegionBcp47Test() throws BrutException, IOException {
compareValuesFiles("values-b+eng+419/strings.xml");

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="test1">test1</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="test1">test1</string>
</resources>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="test1">test1</string>
</resources>