diff --git a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResConfigFlags.java b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResConfigFlags.java index 54167936..a56ec464 100644 --- a/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResConfigFlags.java +++ b/brut.apktool/apktool-lib/src/main/java/brut/androlib/res/data/ResConfigFlags.java @@ -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)); } } diff --git a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java index 1d430c17..11f7c10a 100644 --- a/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java +++ b/brut.apktool/apktool-lib/src/test/java/brut/androlib/BuildAndDecodeTest.java @@ -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"); diff --git a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-b+ast+Latn+IT+AREVELA/strings.xml b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-b+ast+Latn+IT+AREVELA/strings.xml new file mode 100644 index 00000000..35eaf5ef --- /dev/null +++ b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-b+ast+Latn+IT+AREVELA/strings.xml @@ -0,0 +1,4 @@ + + + test1 + \ No newline at end of file diff --git a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-b+en+Latn+419/strings.xml b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-b+en+Latn+419/strings.xml new file mode 100644 index 00000000..35eaf5ef --- /dev/null +++ b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-b+en+Latn+419/strings.xml @@ -0,0 +1,4 @@ + + + test1 + \ No newline at end of file diff --git a/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-en-rUS/strings.xml b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-en-rUS/strings.xml new file mode 100644 index 00000000..35eaf5ef --- /dev/null +++ b/brut.apktool/apktool-lib/src/test/resources/brut/apktool/testapp/res/values-en-rUS/strings.xml @@ -0,0 +1,4 @@ + + + test1 + \ No newline at end of file