AAPT2: Fix pseudolocalization to respect <xliff:g>

The XLIFF 'g' tag specifies content that should NOT be translated.
AAPT2's pseudolocalization process should respect it.

Bug:34064599
Test: make libandroidfw_tests
Change-Id: Ice437d7f0ff246730ee04896fd035e2d846148fb
This commit is contained in:
Adam Lesinski
2017-01-06 15:20:04 -08:00
parent c270de85cc
commit 7542162cb1
12 changed files with 461 additions and 217 deletions

View File

@@ -63,6 +63,14 @@ StringPool::Ref& StringPool::Ref::operator=(const StringPool::Ref& rhs) {
return *this;
}
bool StringPool::Ref::operator==(const Ref& rhs) const {
return entry_->value == rhs.entry_->value;
}
bool StringPool::Ref::operator!=(const Ref& rhs) const {
return entry_->value != rhs.entry_->value;
}
const std::string* StringPool::Ref::operator->() const {
return &entry_->value;
}
@@ -109,6 +117,28 @@ StringPool::StyleRef& StringPool::StyleRef::operator=(
return *this;
}
bool StringPool::StyleRef::operator==(const StyleRef& rhs) const {
if (entry_->str != rhs.entry_->str) {
return false;
}
if (entry_->spans.size() != rhs.entry_->spans.size()) {
return false;
}
auto rhs_iter = rhs.entry_->spans.begin();
for (const Span& span : entry_->spans) {
const Span& rhs_span = *rhs_iter;
if (span.first_char != rhs_span.first_char || span.last_char != rhs_span.last_char ||
span.name != rhs_span.name) {
return false;
}
}
return true;
}
bool StringPool::StyleRef::operator!=(const StyleRef& rhs) const { return !operator==(rhs); }
const StringPool::StyleEntry* StringPool::StyleRef::operator->() const {
return entry_;
}