summaryrefslogtreecommitdiff
path: root/tools/aapt2/cmd/Compile.cpp
diff options
context:
space:
mode:
authorMihai Nita <mnita@google.com>2019-03-26 13:47:45 -0700
committerMihai Nita <mnita@google.com>2019-03-29 17:15:18 -0700
commitd1a6521cc35fc882c9b4c5b31babd7748b445698 (patch)
treeb1fa72782f535e72df99b2f99174fa0ba4d3a36e /tools/aapt2/cmd/Compile.cpp
parente4329dc3ef4c8bc67effb61722019693e92d8518 (diff)
Fix aapt2 pseudo-translating donottranslate* files
Bug: 126423638 Test: After building android doing this in the 'out' folder: Test: Test: ./soong/host/linux-x86/bin/aapt d --values resources \ Test: ./target/product/sailfish/system/product/priv-app/SystemUIGoogle/SystemUIGoogle.apk \ Test: | less Test: Test: search for `system_ui_aod_date_pattern` in the output, found this: Test: (string8) "[éééḾḾḾð one two]" Test: (string8) "<U+200F><U+202E>eeeMMMd<U+202C><U+200F>" Test: (the en-XA and ar-XB pseudo-translated versions of the string) Test: Test: After the fix and rebuild the dump only finds the original English string ("eeeMMMd") Test: Also flashed the image, switched to en-XA, and left the phone around for more than 24 hours. Change-Id: I2fb7c5b5ee7d3d3200410593346682ed16559056
Diffstat (limited to 'tools/aapt2/cmd/Compile.cpp')
-rw-r--r--tools/aapt2/cmd/Compile.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/tools/aapt2/cmd/Compile.cpp b/tools/aapt2/cmd/Compile.cpp
index 2ec1ab31a58c..9b81369fa9f0 100644
--- a/tools/aapt2/cmd/Compile.cpp
+++ b/tools/aapt2/cmd/Compile.cpp
@@ -143,6 +143,8 @@ static bool CompileTable(IAaptContext* context, const CompileOptions& options,
const ResourcePathData& path_data, io::IFile* file, IArchiveWriter* writer,
const std::string& output_path) {
TRACE_CALL();
+ // Filenames starting with "donottranslate" are not localizable
+ bool translatable_file = path_data.name.find("donottranslate") != 0;
ResourceTable table;
{
auto fin = file->OpenInputStream();
@@ -157,9 +159,7 @@ static bool CompileTable(IAaptContext* context, const CompileOptions& options,
ResourceParserOptions parser_options;
parser_options.error_on_positional_arguments = !options.legacy_mode;
-
- // If the filename includes donottranslate, then the default translatable is false.
- parser_options.translatable = path_data.name.find("donottranslate") == std::string::npos;
+ parser_options.translatable = translatable_file;
// If visibility was forced, we need to use it when creating a new resource and also error if
// we try to parse the <public>, <public-group>, <java-symbol> or <symbol> tags.
@@ -172,7 +172,7 @@ static bool CompileTable(IAaptContext* context, const CompileOptions& options,
}
}
- if (options.pseudolocalize) {
+ if (options.pseudolocalize && translatable_file) {
// Generate pseudo-localized strings (en-XA and ar-XB).
// These are created as weak symbols, and are only generated from default
// configuration