summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Eric Fischer <enf@google.com> 2009-09-01 15:20:30 -0700
committer Eric Fischer <enf@google.com> 2009-09-01 15:20:30 -0700
commitc87d25215c842cea370c6a86ce67585fa8da4900 (patch)
tree221eb50bb658c745f0ce5c56588193d565a1ccf3
parentb7559e02803266e5fa9f4496174bc343ecd245ab (diff)
Make it an error to use a bare apostrophe in aapt, and adjust warnings/errors.
In practice, no one ever writes an apostrophe in an aapt string with the intent of using it to quote whitespace -- they always mean to include a literal apostrophe in the string and then are surprised when they find the apostrophe missing. Make this an error so that it is discovered right away instead of waiting until late in QA or after the strings have already been sent for translation. (And fix a recently-introduced string that has exactly this problem.) Silence the warning about an empty span in a string, since this seems to annoy people instead of finding any real problems. Make the error about having a translated string with no base string into a warning, since this is a big pain when making changes to an application that has already had some translations done, and the dead translations should be removed by a later translation import anyway.
-rw-r--r--core/res/res/values-en-rUS/donottranslate-names.xml2
-rw-r--r--libs/utils/ResourceTypes.cpp11
-rw-r--r--tools/aapt/ResourceTable.cpp3
-rw-r--r--tools/aapt/XMLNode.cpp7
4 files changed, 18 insertions, 5 deletions
diff --git a/core/res/res/values-en-rUS/donottranslate-names.xml b/core/res/res/values-en-rUS/donottranslate-names.xml
index 42c8ab48a703..82ba310cde5f 100644
--- a/core/res/res/values-en-rUS/donottranslate-names.xml
+++ b/core/res/res/values-en-rUS/donottranslate-names.xml
@@ -147,7 +147,7 @@
MD, MS, PH.D., PHD, SR, V, VI, VII, VIII, X
</string>
<string name="common_last_name_prefixes">
- D', DE, DEL, DI, LA, LE, MC, SAN, ST, TER, VAN, VON
+ D\', DE, DEL, DI, LA, LE, MC, SAN, ST, TER, VAN, VON
</string>
<string name="common_name_conjunctions">
&amp;, AND, OR
diff --git a/libs/utils/ResourceTypes.cpp b/libs/utils/ResourceTypes.cpp
index 0831f4a0c0f0..f80843d8dc9e 100644
--- a/libs/utils/ResourceTypes.cpp
+++ b/libs/utils/ResourceTypes.cpp
@@ -3284,7 +3284,16 @@ bool ResTable::collectString(String16* outString,
break;
}
if (c == '\'' && (quoted == 0 || quoted == '\'')) {
- break;
+ /*
+ * In practice, when people write ' instead of \'
+ * in a string, they are doing it by accident
+ * instead of really meaning to use ' as a quoting
+ * character. Warn them so they don't lose it.
+ */
+ if (outErrorMsg) {
+ *outErrorMsg = "Apostrophe not preceded by \\";
+ }
+ return false;
}
}
p++;
diff --git a/tools/aapt/ResourceTable.cpp b/tools/aapt/ResourceTable.cpp
index 95a238401832..f9d243423dca 100644
--- a/tools/aapt/ResourceTable.cpp
+++ b/tools/aapt/ResourceTable.cpp
@@ -2364,13 +2364,12 @@ ResourceTable::validateLocalizations(void)
String8 region(config.string(), 2);
if (configSet.find(region) == configSet.end()) {
if (configSet.count(defaultLocale) == 0) {
- fprintf(stdout, "aapt: error: "
+ fprintf(stdout, "aapt: warning: "
"*** string '%s' has no default or required localization "
"for '%s' in %s\n",
String8(nameIter->first).string(),
config.string(),
mBundle->getResourceSourceDirs()[0]);
- err = UNKNOWN_ERROR;
}
}
}
diff --git a/tools/aapt/XMLNode.cpp b/tools/aapt/XMLNode.cpp
index 6daa0d206da6..d4d2a45c2d0f 100644
--- a/tools/aapt/XMLNode.cpp
+++ b/tools/aapt/XMLNode.cpp
@@ -219,7 +219,12 @@ moveon:
}
spanStack.pop();
- if (empty) {
+ /*
+ * This warning seems to be just an irritation to most people,
+ * since it is typically introduced by translators who then never
+ * see the warning.
+ */
+ if (0 && empty) {
fprintf(stderr, "%s:%d: warning: empty '%s' span found in text '%s'\n",
fileName, inXml->getLineNumber(),
String8(spanTag).string(), String8(*outString).string());