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

Commit 923546df authored by Steve Kondik's avatar Steve Kondik Committed by Gerrit Code Review
Browse files

Merge "aapt: add check for untranslatable "string-array"s" into cm-10.1

parents c8f8aa0e 38c685c7
Loading
Loading
Loading
Loading
+16 −1
Original line number Diff line number Diff line
@@ -1369,17 +1369,32 @@ status_t compileResourceFile(Bundle* bundle,
                    }
                }
            } else if (strcmp16(block.getElementName(&len), string_array16.string()) == 0) {
                // Note the existence and locale of every string we process
                char rawLocale[16];
                curParams.getLocale(rawLocale);
                String8 locale(rawLocale);
                String16 name;
                // Check whether these strings need valid formats.
                // (simplified form of what string16 does above)
                size_t n = block.getAttributeCount();
                for (size_t i = 0; i < n; i++) {
                    size_t length;
                    const uint16_t* attr = block.getAttributeName(i, &length);
                    if (strcmp16(attr, translatable16.string()) == 0
                    if (strcmp16(attr, name16.string()) == 0) {
                        name.setTo(block.getAttributeStringValue(i, &length));
                    } else if (strcmp16(attr, translatable16.string()) == 0
                            || strcmp16(attr, formatted16.string()) == 0) {
                        const uint16_t* value = block.getAttributeStringValue(i, &length);
                        if (strcmp16(value, false16.string()) == 0) {
                            curIsFormatted = false;
                            // Untranslatable strings must only exist in the default [empty] locale
                            if (locale.size() > 0) {
                                fprintf(stderr, "aapt: error: string-array '%s' in %s marked untranslatable but exists"
                                        " in locale '%s'\n", String8(name).string(),
                                        bundle->getResourceSourceDirs()[0],
                                        locale.string());
                                hasErrors = localHasErrors = true;
                            }
                            break;
                        }
                    }