Skip to content

Commit 43dc6e9

Browse files
Merge pull request openboard-team#647 from amcoder36/36.better_armenian_support
Better support for Armenian language
2 parents 6c7582a + 80e4e07 commit 43dc6e9

7 files changed

Lines changed: 73 additions & 29 deletions

File tree

app/src/main/java/org/dslul/openboard/inputmethod/keyboard/internal/KeyboardTextsTable.java

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2169,27 +2169,35 @@ public static String[] getTextsTable(final Locale locale) {
21692169
/* morekeys_nordic_row2_11 ~ */
21702170
null, null, null, null, null, null, null,
21712171
/* ~ morekeys_swiss_row2_11 */
2172-
// U+055E: "՞" ARMENIAN QUESTION MARK
2173-
// U+055C: "՜" ARMENIAN EXCLAMATION MARK
2174-
// U+055A: "՚" ARMENIAN APOSTROPHE
2175-
// U+0559: "ՙ" ARMENIAN MODIFIER LETTER LEFT HALF RING
2176-
// U+055D: "՝" ARMENIAN COMMA
2177-
// U+055B: "՛" ARMENIAN EMPHASIS MARK
2178-
// U+058A: "֊" ARMENIAN HYPHEN
2179-
// U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
2180-
// U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
2181-
// U+055F: "՟" ARMENIAN ABBREVIATION MARK
2182-
/* morekeys_punctuation */ "!autoColumnOrder!8,\\,,\u055E,\u055C,.,\u055A,\u0559,?,!,\u055D,\u055B,\u058A,\u00BB,\u00AB,\u055F,;,:",
2183-
/* keyspec_tablet_comma */ "\u055D",
2172+
//
2173+
// ( U+0028 "(" Բացվող փակագիծ - OPENING PARENTHESES
2174+
// ) U+0029 ")" Փակվող փակագիծ - CLOSING PARENTHESES
2175+
// ' U+0027 "'" Ապաթարց - APOSTROPHE
2176+
// … U+2026 "…" Կախման կետեր - HORIZONTAL ELLIPSIS
2177+
// ՞ U+055E "՞" Հարցական - ARMENIAN QUESTION MARK
2178+
// ՜ U+055C "՜" Բացականչական - ARMENIAN EXCLAMATION MARK
2179+
// ՛ U+055B "՛" Շեշտ - ARMENIAN EMPHASIS MARK
2180+
// ՝ U+055D "՝" Բութ - ARMENIAN COMMA
2181+
// !! (the unicode name is Armenian Comma, which isn't really accurate since Armenian Comma is U+002C)
2182+
// ֊ U+058A "֊" Միության գծիկ - ARMENIAN HYPHEN
2183+
// ― U+2015 "―" Անջատման գժիկ - ARMENIAN SEPARATION MARK
2184+
// « U+00AB "«" Բացվող չակերտ - LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
2185+
// » U+00BB "»" Փակվող չակերտ - RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
2186+
// , U+002C "," Ստօրակետ - ARMENIAN COMMA
2187+
// ։ U+0589 "։" Վերջակետ - ARMENIAN COLON
2188+
// ․ U+2024 "․" Միջակետ - One dot leader
2189+
//
2190+
/* morekeys_punctuation */ "!autoColumnOrder!8,\\,,\u055E,\u055C,\u2024,\u2026,',=,/,\u055D,\u055B,\u058A,\u00BB,\u00AB,\u2015,),(",
2191+
/* keyspec_tablet_comma */ ",",
21842192
/* morekeys_star ~ */
21852193
null, null, null, null, null, null, null, null, null, null, null, null, null, null, null,
21862194
/* ~ keyspec_right_single_angle_quote */
21872195
// U+058F: "֏" ARMENIAN DRAM SIGN
21882196
// TODO: Enable this when we have glyph for the following letter
21892197
// <string name="keyspec_currency">&#x058F;</string>
21902198
//
2191-
// U+055D: "՝" ARMENIAN COMMA
2192-
/* keyspec_comma */ "\u055D",
2199+
// U+002C: "," ARMENIAN COMMA
2200+
/* keyspec_comma */ ",",
21932201
/* morekeys_tablet_comma */ null,
21942202
/* keyhintlabel_period */ null,
21952203
// U+055E: "՞" ARMENIAN QUESTION MARK

app/src/main/java/org/dslul/openboard/inputmethod/latin/spellcheck/AndroidSpellCheckerService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ private static String getKeyboardLayoutNameForLocale(final Locale locale) {
113113
switch (script) {
114114
case ScriptUtils.SCRIPT_LATIN:
115115
return "qwerty";
116+
case ScriptUtils.SCRIPT_ARMENIAN:
117+
return "armenian_phonetic";
116118
case ScriptUtils.SCRIPT_CYRILLIC:
117119
return "east_slavic";
118120
case ScriptUtils.SCRIPT_GREEK:

app/src/main/java/org/dslul/openboard/inputmethod/latin/spellcheck/AndroidWordLevelSpellCheckerSession.java

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,8 @@
4545
import java.util.ArrayList;
4646
import java.util.List;
4747
import java.util.Locale;
48+
import java.util.Map;
49+
import java.util.TreeMap;
4850

4951
public abstract class AndroidWordLevelSpellCheckerSession extends Session {
5052
private static final String TAG = AndroidWordLevelSpellCheckerSession.class.getSimpleName();
@@ -62,6 +64,16 @@ public abstract class AndroidWordLevelSpellCheckerSession extends Session {
6264
private static final String quotesRegexp =
6365
"(\\u0022|\\u0027|\\u0060|\\u00B4|\\u2018|\\u2018|\\u201C|\\u201D)";
6466

67+
private static final Map<Integer, String> scriptToPunctuationRegexMap = new TreeMap<>();
68+
69+
static {
70+
// TODO: add other non-English language specific punctuation later.
71+
scriptToPunctuationRegexMap.put(
72+
ScriptUtils.SCRIPT_ARMENIAN,
73+
"(\\u0028|\\u0029|\\u0027|\\u2026|\\u055E|\\u055C|\\u055B|\\u055D|\\u058A|\\u2015|\\u00AB|\\u00BB|\\u002C|\\u0589|\\u2024)"
74+
);
75+
}
76+
6577
private static final class SuggestionsParams {
6678
public final String[] mSuggestions;
6779
public final int mFlags;
@@ -260,12 +272,22 @@ protected SuggestionsInfo onGetSuggestionsInternal(
260272
final TextInfo textInfo, final NgramContext ngramContext, final int suggestionsLimit) {
261273
try {
262274
updateLocale();
263-
final String text = textInfo.getText().
275+
// It's good to keep this not local specific since the standard
276+
// ones may show up in other languages also.
277+
String text = textInfo.getText().
264278
replaceAll(AndroidSpellCheckerService.APOSTROPHE,
265279
AndroidSpellCheckerService.SINGLE_QUOTE).
266280
replaceAll("^" + quotesRegexp, "").
267281
replaceAll(quotesRegexp + "$", "");
268282

283+
final String localeRegex = scriptToPunctuationRegexMap.get(
284+
ScriptUtils.getScriptFromSpellCheckerLocale(mLocale)
285+
);
286+
287+
if (localeRegex != null) {
288+
text = text.replaceAll(localeRegex, "");
289+
}
290+
269291
if (!mService.hasMainDictionaryForLocale(mLocale)) {
270292
return AndroidSpellCheckerService.getNotInDictEmptySuggestions(
271293
false /* reportAsTypo */);

app/src/main/res/raw/main_hy.dict

1.98 MB
Binary file not shown.

app/src/main/res/xml/spellchecker.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@
5555
android:label="@string/subtype_generic"
5656
android:subtypeLocale="ru"
5757
/>
58+
<subtype
59+
android:label="@string/subtype_generic"
60+
android:subtypeLocale="hy"
61+
/>
5862
<subtype
5963
android:label="@string/subtype_generic"
6064
android:subtypeLocale="pt_BR"
1.28 MB
Binary file not shown.

tools/make-keyboard-text/src/main/resources/values-hy/donottranslate-more-keys.xml

Lines changed: 22 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -23,17 +23,25 @@
2323
U+0532: "Բ" ARMENIAN CAPITAL LETTER BEN
2424
U+0533: "Գ" ARMENIAN CAPITAL LETTER GIM -->
2525
<string name="keylabel_to_alpha">&#x0531;&#x0532;&#x0533;</string>
26-
<!-- U+055E: "՞" ARMENIAN QUESTION MARK
27-
U+055C: "՜" ARMENIAN EXCLAMATION MARK
28-
U+055A: "՚" ARMENIAN APOSTROPHE
29-
U+0559: "ՙ" ARMENIAN MODIFIER LETTER LEFT HALF RING
30-
U+055D: "՝" ARMENIAN COMMA
31-
U+055B: "՛" ARMENIAN EMPHASIS MARK
32-
U+058A: "֊" ARMENIAN HYPHEN
33-
U+00BB: "»" RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
34-
U+00AB: "«" LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
35-
U+055F: "՟" ARMENIAN ABBREVIATION MARK -->
36-
<string name="morekeys_punctuation">"!autoColumnOrder!8,\\,,&#x055E;,&#x055C;,.,&#x055A;,&#x0559;,?,!,&#x055D;,&#x055B;,&#x058A;,&#x00BB;,&#x00AB;,&#x055F;,;,:"</string>
26+
<!--
27+
&#x0028; U+0028 "(" Բացվող փակագիծ - OPENING PARENTHESES
28+
&#x0029; U+0029 ")" Փակվող փակագիծ - CLOSING PARENTHESES
29+
&#x0027; U+0027 "'" Ապաթարց - APOSTROPHE
30+
&#x2026; U+2026 "…" Կախման կետեր - HORIZONTAL ELLIPSIS
31+
&#x055E; U+055E "՞" Հարցական - ARMENIAN QUESTION MARK
32+
&#x055C; U+055C "՜" Բացականչական - ARMENIAN EXCLAMATION MARK
33+
&#x055B; U+055B "՛" Շեշտ - ARMENIAN EMPHASIS MARK
34+
&#x055D; U+055D "՝" Բութ - ARMENIAN COMMA
35+
!! (the unicode name is Armenian Comma, which isn't really accurate since Armenian Comma is U+002C)
36+
&#x058A; U+058A "֊" Միության գծիկ - ARMENIAN HYPHEN
37+
&#x2015; U+2015 "―" Անջատման գժիկ - ARMENIAN SEPARATION MARK
38+
&#x00AB; U+00AB "«" Բացվող չակերտ - LEFT-POINTING DOUBLE ANGLE QUOTATION MARK
39+
&#x00BB; U+00BB "»" Փակվող չակերտ - RIGHT-POINTING DOUBLE ANGLE QUOTATION MARK
40+
&#x002C; U+002C "," Ստօրակետ - ARMENIAN COMMA
41+
&#x0589; U+0589 "։" Վերջակետ - ARMENIAN COLON
42+
&#x2024; U+2024 "․" Միջակետ - One dot leader
43+
-->
44+
<string name="morekeys_punctuation">"!autoColumnOrder!8,\\,,&#x055E;,&#x055C;,&#x2024;,&#x2026;,&#x0027;,&#x003D;,&#x002F;,&#x055D;,&#x055B;,&#x058A;,&#x00BB;,&#x00AB;,&#x2015;,&#x0029;,&#x0028;"</string>
3745
<!-- U+055E: "՞" ARMENIAN QUESTION MARK
3846
U+00BF: "¿" INVERTED QUESTION MARK -->
3947
<string name="morekeys_question">&#x055E;,&#x00BF;</string>
@@ -44,9 +52,9 @@
4452
<!-- TODO: Enable this when we have glyph for the following letter
4553
<string name="keyspec_currency">&#x058F;</string>
4654
-->
47-
<!-- U+055D: "՝" ARMENIAN COMMA -->
48-
<string name="keyspec_comma">&#x055D;</string>
49-
<string name="keyspec_tablet_comma">&#x055D;</string>
55+
<!-- U+002C: "," ARMENIAN COMMA -->
56+
<string name="keyspec_comma">&#x002C;</string>
57+
<string name="keyspec_tablet_comma">&#x002C;</string>
5058
<!-- U+0589: "։" ARMENIAN FULL STOP -->
5159
<string name="keyspec_period">&#x0589;</string>
5260
<string name="keyspec_tablet_period">&#x0589;</string>

0 commit comments

Comments
 (0)