Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Unverified Commit 6aa895db authored by Chirayu Desai's avatar Chirayu Desai Committed by Michael Bestas
Browse files

aapt: add check for untranslatable "string-array"s



Change-Id: Id884af0505c0bcdfa20b400fcdd54f699f8ef38f
Signed-off-by: default avatarChirayu Desai <cdesai@cyanogenmod.org>
parent df71689a
Loading
Loading
Loading
Loading
+17 −1
Original line number Diff line number Diff line
@@ -1462,6 +1462,11 @@ status_t compileResourceFile(Bundle* bundle,
                    }
                }
            } else if (strcmp16(block.getElementName(&len), string_array16.string()) == 0) {
                // Note the existence and locale of every string array we process
                char rawLocale[RESTABLE_MAX_LOCALE_LEN];
                curParams.getBcp47Locale(rawLocale);
                String8 locale(rawLocale);
                String16 name;
                // Check whether these strings need valid formats.
                // (simplified form of what string16 does above)
                bool isTranslatable = false;
@@ -1472,7 +1477,9 @@ status_t compileResourceFile(Bundle* bundle,
                for (size_t i = 0; i < n; i++) {
                    size_t length;
                    const char16_t* attr = block.getAttributeName(i, &length);
                    if (strcmp16(attr, formatted16.string()) == 0) {
                    if (strcmp16(attr, name16.string()) == 0) {
                        name.setTo(block.getAttributeStringValue(i, &length));
                    } else if (strcmp16(attr, formatted16.string()) == 0) {
                        const char16_t* value = block.getAttributeStringValue(i, &length);
                        if (strcmp16(value, false16.string()) == 0) {
                            curIsFormatted = false;
@@ -1481,6 +1488,15 @@ status_t compileResourceFile(Bundle* bundle,
                        const char16_t* value = block.getAttributeStringValue(i, &length);
                        if (strcmp16(value, false16.string()) == 0) {
                            isTranslatable = false;
                            // Untranslatable string arrays must only exist
                            // in the default [empty] locale
                            if (locale.size() > 0) {
                                SourcePos(in->getPrintableSource(), block.getLineNumber()).warning(
                                        "string-array '%s' marked untranslatable but exists"
                                        " in locale '%s'\n", String8(name).string(),
                                        locale.string());
                                // hasErrors = localHasErrors = true;
                            }
                        }
                    }
                }