summaryrefslogtreecommitdiffstats
path: root/tools/aapt/XMLNode.cpp
diff options
context:
space:
mode:
authorAnton Krumin <antkrumin@google.com>2014-03-12 14:46:44 -0700
committerAnton Krumin <antkrumin@google.com>2014-04-09 16:59:48 -0700
commita2ef5c0d4fb863c0382e77ae00f986a019b11cbe (patch)
treed6c10bedf5d762e0fc0bd10b38f381ccefefa248 /tools/aapt/XMLNode.cpp
parentecdf9b199ac9659c37c34c0b23084199acea80bf (diff)
downloadframeworks_base-a2ef5c0d4fb863c0382e77ae00f986a019b11cbe.zip
frameworks_base-a2ef5c0d4fb863c0382e77ae00f986a019b11cbe.tar.gz
frameworks_base-a2ef5c0d4fb863c0382e77ae00f986a019b11cbe.tar.bz2
Pseudolocalizer improvements.
Fixes accented pseudolocalization and adds RTL pseudolocale. This change contains following modifications in the pseudolocalization logic: 1) zz_ZZ pseudolocale was removed; 2) en_XA pseudolocale was added for pseudo-accented; 3) ar_XB pseudolocale was added for pseudo-rtl; 4) Pseudo RTL localization functionality was implemented; 5) Text expansion functionality was implemented; 6) Text bracketing was implemented; 7) Couple of issues of previous implementation were fixed. Change-Id: I9f7f27bed717e39e82717d15c398decffc8bec3c Signed-off-by: Anton Krumin <antkrumin@google.com>
Diffstat (limited to 'tools/aapt/XMLNode.cpp')
-rw-r--r--tools/aapt/XMLNode.cpp42
1 files changed, 35 insertions, 7 deletions
diff --git a/tools/aapt/XMLNode.cpp b/tools/aapt/XMLNode.cpp
index a663ad5..607d419 100644
--- a/tools/aapt/XMLNode.cpp
+++ b/tools/aapt/XMLNode.cpp
@@ -187,7 +187,7 @@ status_t parseStyledString(Bundle* bundle,
String16* outString,
Vector<StringPool::entry_style_span>* outSpans,
bool isFormatted,
- bool pseudolocalize)
+ PseudolocalizationMethod pseudolocalize)
{
Vector<StringPool::entry_style_span> spanStack;
String16 curString;
@@ -198,21 +198,30 @@ status_t parseStyledString(Bundle* bundle,
size_t len;
ResXMLTree::event_code_t code;
+ // Bracketing if pseudolocalization accented method specified.
+ if (pseudolocalize == PSEUDO_ACCENTED) {
+ curString.append(String16(String8("[")));
+ }
while ((code=inXml->next()) != ResXMLTree::END_DOCUMENT && code != ResXMLTree::BAD_DOCUMENT) {
-
if (code == ResXMLTree::TEXT) {
String16 text(inXml->getText(&len));
if (firstTime && text.size() > 0) {
firstTime = false;
if (text.string()[0] == '@') {
// If this is a resource reference, don't do the pseudoloc.
- pseudolocalize = false;
+ pseudolocalize = NO_PSEUDOLOCALIZATION;
}
}
- if (xliffDepth == 0 && pseudolocalize) {
- std::string orig(String8(text).string());
- std::string pseudo = pseudolocalize_string(orig);
- curString.append(String16(String8(pseudo.c_str())));
+ if (xliffDepth == 0 && pseudolocalize > 0) {
+ String16 pseudo;
+ if (pseudolocalize == PSEUDO_ACCENTED) {
+ pseudo = pseudolocalize_string(text);
+ } else if (pseudolocalize == PSEUDO_BIDI) {
+ pseudo = pseudobidi_string(text);
+ } else {
+ pseudo = text;
+ }
+ curString.append(pseudo);
} else {
if (isFormatted && hasSubstitutionErrors(fileName, inXml, text) != NO_ERROR) {
return UNKNOWN_ERROR;
@@ -352,6 +361,25 @@ moveon:
}
}
+ // Bracketing if pseudolocalization accented method specified.
+ if (pseudolocalize == PSEUDO_ACCENTED) {
+ const char16_t* str = outString->string();
+ const char16_t* p = str;
+ const char16_t* e = p + outString->size();
+ int words_cnt = 0;
+ while (p < e) {
+ if (isspace(*p)) {
+ words_cnt++;
+ }
+ p++;
+ }
+ unsigned int length = words_cnt > 3 ? outString->size() :
+ outString->size() / 2;
+ curString.append(String16(String8(" ")));
+ curString.append(pseudo_generate_expansion(length));
+ curString.append(String16(String8("]")));
+ }
+
if (code == ResXMLTree::BAD_DOCUMENT) {
SourcePos(String8(fileName), inXml->getLineNumber()).error(
"Error parsing XML\n");