summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorChirayu Desai <cdesai@cyanogenmod.org>2013-05-05 19:35:45 +0530
committerGerrit Code Review <gerrit@cyanogenmod.org>2016-01-26 16:12:02 -0800
commita96ede25798b4fe58e52801967bdd8c994d0839f (patch)
treee5716c00495e8337f852b36f0c2333a385e85ca1 /tools
parent90458aff943d2c35df0e6adeb573d3faf0b71c73 (diff)
downloadframeworks_base-a96ede25798b4fe58e52801967bdd8c994d0839f.zip
frameworks_base-a96ede25798b4fe58e52801967bdd8c994d0839f.tar.gz
frameworks_base-a96ede25798b4fe58e52801967bdd8c994d0839f.tar.bz2
aapt: add check for untranslatable "string-array"s
Change-Id: Id884af0505c0bcdfa20b400fcdd54f699f8ef38f Signed-off-by: Chirayu Desai <cdesai@cyanogenmod.org>
Diffstat (limited to 'tools')
-rw-r--r--tools/aapt/ResourceTable.cpp18
1 files changed, 17 insertions, 1 deletions
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 889883a..fb0299e 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -1467,6 +1467,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;
@@ -1477,7 +1482,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;
@@ -1486,6 +1493,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;
+ }
}
}
}