Fix test resource declarations and parsing a bit

Change-Id: I882a41b2934c48f4405f1ea5bf4d6ad41e87322c
This commit is contained in:
Tadashi G. Takaoka 2014-02-14 11:01:38 +09:00
parent d4469756be
commit e422c94634
10 changed files with 20 additions and 35 deletions

View file

@ -161,7 +161,7 @@
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
<key-style
latin:styleName="comKeyStyle"
latin:keySpec="!text/keylabel_for_popular_domain|!text/keylabel_for_popular_domain"
latin:keySpec="!text/keylabel_for_popular_domain"
latin:keyLabelFlags="autoXScale|fontNormal|hasPopupHint|preserveCase"
latin:moreKeys="!text/more_keys_for_popular_domain" />
</merge>

View file

@ -149,7 +149,7 @@
latin:parentStyle="baseForLayoutSwitchKeyStyle" />
<key-style
latin:styleName="comKeyStyle"
latin:keySpec="!text/keylabel_for_popular_domain|!text/keylabel_for_popular_domain"
latin:keySpec="!text/keylabel_for_popular_domain"
latin:keyLabelFlags="autoXScale|fontNormal|hasPopupHint|preserveCase"
latin:moreKeys="!text/more_keys_for_popular_domain"
latin:backgroundType="functional" />

View file

@ -75,7 +75,7 @@
<!-- U+066A: "٪" ARABIC PERCENT SIGN -->
<string name="keylabel_for_symbols_percent">&#x066A;</string>
<!-- U+00BF: "¿" INVERTED QUESTION MARK -->
<string name="more_keys_for_question">\?,&#x00BF;</string>
<string name="more_keys_for_question">?,&#x00BF;</string>
<string name="more_keys_for_symbols_semicolon">;</string>
<!-- U+2030: "‰" PER MILLE SIGN -->
<string name="more_keys_for_symbols_percent">\\%,&#x2030;</string>
@ -85,7 +85,7 @@
<string name="keylabel_for_tablet_comma">"&#x060C;"</string>
<string name="keyhintlabel_for_tablet_comma">"&#x061F;"</string>
<string name="more_keys_for_tablet_comma">"!fixedColumnOrder!4,:,!,&#x061F;,&#x061B;,-,/,\",\'"</string>
<string name="more_keys_for_punctuation">"!fixedColumnOrder!8,\",\',#,-,:,!,&#x060C;,&#x061F;,\@,&amp;,\\%,+,&#x061B;,/,(|),)|("</string>
<string name="more_keys_for_punctuation">"!fixedColumnOrder!8,\",\',#,-,:,!,&#x060C;,&#x061F;,@,&amp;,\\%,+,&#x061B;,/,(|),)|("</string>
<!-- U+266A: "♪" EIGHTH NOTE -->
<string name="more_keys_for_bullet">&#x266A;</string>
<!-- U+2605: "★" BLACK STAR

View file

@ -71,8 +71,8 @@
U+0142: "ł" LATIN SMALL LETTER L WITH STROKE -->
<string name="more_keys_for_l">l&#x00B7;l,&#x0142;</string>
<!-- U+00B7: "·" MIDDLE DOT -->
<string name="more_keys_for_punctuation">"!fixedColumnOrder!9,;,/,(,),#,&#x00B7;,!,\\,,\?,&amp;,\\%,+,\",-,:,',\@"</string>
<string name="more_keys_for_tablet_punctuation">"!fixedColumnOrder!8,;,/,(,),#,&#x00B7;,',\\,,&amp;,\\%,+,\",-,:,\@"</string>
<string name="more_keys_for_punctuation">"!fixedColumnOrder!9,;,/,(,),#,&#x00B7;,!,\\,,?,&amp;,\\%,+,\",-,:,',@"</string>
<string name="more_keys_for_tablet_punctuation">"!fixedColumnOrder!8,;,/,(,),#,&#x00B7;,',\\,,&amp;,\\%,+,\",-,:,@"</string>
<!-- U+00E7: "ç" LATIN SMALL LETTER C WITH CEDILLA -->
<string name="keylabel_for_spanish_row2_10">&#x00E7;</string>
</resources>

View file

@ -69,5 +69,5 @@
<string name="more_keys_for_c">&#x00E7;,&#x0107;,&#x010D;</string>
<!-- U+00A1: "¡" INVERTED EXCLAMATION MARK
U+00BF: "¿" INVERTED QUESTION MARK -->
<string name="more_keys_for_punctuation">"!fixedColumnOrder!9,&#x00A1;,;,/,(,),#,!,\\,,\?,&#x00BF;,&amp;,\\%,+,\",-,:,',\@"</string>
<string name="more_keys_for_punctuation">"!fixedColumnOrder!9,&#x00A1;,;,/,(,),#,!,\\,,?,&#x00BF;,&amp;,\\%,+,\",-,:,',@"</string>
</resources>

View file

@ -75,7 +75,7 @@
<!-- U+066A: "٪" ARABIC PERCENT SIGN -->
<string name="keylabel_for_symbols_percent">&#x066A;</string>
<!-- U+00BF: "¿" INVERTED QUESTION MARK -->
<string name="more_keys_for_question">\?,&#x00BF;</string>
<string name="more_keys_for_question">?,&#x00BF;</string>
<string name="more_keys_for_symbols_semicolon">;</string>
<!-- U+2030: "‰" PER MILLE SIGN -->
<string name="more_keys_for_symbols_percent">\\%,&#x2030;</string>
@ -92,7 +92,7 @@
<!-- U+061F: "؟" ARABIC QUESTION MARK
U+060C: "،" ARABIC COMMA
U+061B: "؛" ARABIC SEMICOLON -->
<string name="more_keys_for_punctuation">"!fixedColumnOrder!8,\",\',#,-,:,!,&#x060C;,&#x061F;,\@,&amp;,\\%,+,&#x061B;,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis"</string>
<string name="more_keys_for_punctuation">"!fixedColumnOrder!8,\",\',#,-,:,!,&#x060C;,&#x061F;,@,&amp;,\\%,+,&#x061B;,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis"</string>
<!-- U+266A: "♪" EIGHTH NOTE -->
<string name="more_keys_for_bullet">&#x266A;</string>
<!-- U+2605: "★" BLACK STAR

View file

@ -44,7 +44,7 @@
<!-- U+0966: "" DEVANAGARI DIGIT ZERO -->
<string name="keylabel_for_symbols_0">&#x0966;</string>
<!-- Label for "switch to symbols" key. -->
<string name="label_to_symbol_key">\?&#x0967;&#x0968;&#x0969;</string>
<string name="label_to_symbol_key">?&#x0967;&#x0968;&#x0969;</string>
<!-- Label for "switch to symbols with microphone" key. This string shouldn't include the "mic"
part because it'll be appended by the code. -->
<string name="label_to_symbol_with_microphone_key">&#x0967;&#x0968;&#x0969;</string>

View file

@ -44,7 +44,7 @@
<!-- U+0966: "" DEVANAGARI DIGIT ZERO -->
<string name="keylabel_for_symbols_0">&#x0966;</string>
<!-- Label for "switch to symbols" key. -->
<string name="label_to_symbol_key">\?&#x0967;&#x0968;&#x0969;</string>
<string name="label_to_symbol_key">?&#x0967;&#x0968;&#x0969;</string>
<!-- Label for "switch to symbols with microphone" key. This string shouldn't include the "mic"
part because it'll be appended by the code. -->
<string name="label_to_symbol_with_microphone_key">&#x0967;&#x0968;&#x0969;</string>

View file

@ -83,8 +83,8 @@
<string name="more_keys_for_currency_dollar">&#x00A2;,&#x00A3;,&#x20AC;,&#x00A5;,&#x20B1;</string>
<string name="keylabel_for_currency">$</string>
<string name="more_keys_for_currency">$,&#x00A2;,&#x20AC;,&#x00A3;,&#x00A5;,&#x20B1;</string>
<string name="more_keys_for_punctuation">"!fixedColumnOrder!8,;,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis,#,!,\\,,\?,&amp;,\\%,+,\",-,:,',\@"</string>
<string name="more_keys_for_tablet_punctuation">"!fixedColumnOrder!7,;,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis,#,',\\,,&amp;,\\%,+,\",-,:,\@"</string>
<string name="more_keys_for_punctuation">"!fixedColumnOrder!8,;,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis,#,!,\\,,?,&amp;,\\%,+,\",-,:,',@"</string>
<string name="more_keys_for_tablet_punctuation">"!fixedColumnOrder!7,;,/,!text/keyspec_left_parenthesis,!text/keyspec_right_parenthesis,#,',\\,,&amp;,\\%,+,\",-,:,@"</string>
<!-- U+00F1: "ñ" LATIN SMALL LETTER N WITH TILDE -->
<string name="keylabel_for_spanish_row2_10">&#x00F1;</string>
<!-- U+2020: "†" DAGGER
@ -115,7 +115,7 @@
<string name="keylabel_for_symbols_9">9</string>
<string name="keylabel_for_symbols_0">0</string>
<!-- Label for "switch to symbols" key. -->
<string name="label_to_symbol_key">\?123</string>
<string name="label_to_symbol_key">?123</string>
<!-- Label for "switch to symbols with microphone" key. This string shouldn't include the "mic"
part because it'll be appended by the code. -->
<string name="label_to_symbol_with_microphone_key">123</string>
@ -189,7 +189,7 @@
<string name="keylabel_for_tablet_period">.</string>
<string name="keyhintlabel_for_tablet_period"></string>
<string name="more_keys_for_tablet_period">!text/more_keys_for_tablet_punctuation</string>
<string name="keylabel_for_symbols_question">\?</string>
<string name="keylabel_for_symbols_question">?</string>
<string name="keylabel_for_symbols_semicolon">;</string>
<string name="keylabel_for_symbols_percent">%</string>
<!-- U+00A1: "¡" INVERTED EXCLAMATION MARK -->
@ -205,11 +205,11 @@
<string name="keylabel_for_w">w</string>
<string name="keylabel_for_y">y</string>
<string name="keylabel_for_x">x</string>
<string name="more_keys_for_am_pm">!fixedColumnOrder!2,!hasLabels!,\@string/label_time_am,\@string/label_time_pm</string>
<string name="more_keys_for_am_pm">!fixedColumnOrder!2,!hasLabels!,!text/label_time_am,!text/label_time_pm</string>
<string name="settings_as_more_key">!icon/settings_key|!code/key_settings</string>
<string name="shortcut_as_more_key">!icon/shortcut_key|!code/key_shortcut</string>
<string name="action_next_as_more_key">!hasLabels!,\@string/label_next_key|!code/key_action_next</string>
<string name="action_previous_as_more_key">!hasLabels!,\@string/label_previous_key|!code/key_action_previous</string>
<string name="action_next_as_more_key">!hasLabels!,!text/label_next_key|!code/key_action_next</string>
<string name="action_previous_as_more_key">!hasLabels!,!text/label_previous_key|!code/key_action_previous</string>
<!-- Label for "switch to more symbol" modifier key ("= \ <"). Must be short to fit on key! -->
<string name="label_to_more_symbol_key">= \\\\ &lt;</string>
<!-- Label for "switch to more symbol" modifier key on tablets. Must be short to fit on key! -->

View file

@ -29,6 +29,7 @@ import java.util.Comparator;
import java.util.HashMap;
import java.util.Locale;
import java.util.jar.JarFile;
import java.util.regex.Pattern;
public class MoreKeysResources {
private static final String TEXT_RESOURCE_NAME = "donottranslate-more-keys.xml";
@ -287,23 +288,7 @@ public class MoreKeysResources {
sb.append(String.format("\\u%04X", (int)c));
}
}
return replaceIncompatibleEscape(sb.toString());
}
private static String replaceIncompatibleEscape(final String text) {
String t = text;
t = replaceAll(t, "\\?", "?");
t = replaceAll(t, "\\@", "@");
t = replaceAll(t, "@string/", "!text/");
return t;
}
private static String replaceAll(final String text, final String target, final String replace) {
String t = text;
while (t.indexOf(target) >= 0) {
t = t.replace(target, replace);
}
return t;
return sb.toString();
}
private static void close(final Closeable stream) {