diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 4e461ad3..6403af06 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -53,7 +53,10 @@ To support a new language one needs to: - Create a new `.yml` file in `assets/languages/definitions/` and define the language properties. - `locale` contains the language and the country codes (e.g. "en-US", "es-AR", "it-IT"). Refer to the list of [supported locales in Java](https://www.oracle.com/java/technologies/javase/jdk8-jre8-suported-locales.html#util-text). - `dictionaryFile` is the name of the dictionary in `assets/languages/dictionaries/` folder. - - `layout` contains the letters and punctuation marks associated with each key. For 0-key and 1-key using `[DEFAULT]`, will be fine for most languages. However, if the language has extra punctuation marks, like Spanish, you could complement the list: `[DEFAULT, ¡, ¿]` + - `layout` contains the letters and punctuation marks associated with each key. + - For 0-key `[SPECIAL]`, will be fine in most languages, but you could define your own set of special characters, for example: `[@, #, $]`. + - For 1-key, you could use `[PUNCTUATION]` and have standard English/computer punctuation; or `[PUNCTUATION_FR]` that includes the French quotation marks: `«`, `»`; or `[PUNCTUATION_DE]` that includes the German quotation marks: `„`, `“`. And if the language has extra punctuation marks, like Spanish, you could complement the list like this: `[PUNCTUATION, ¡, ¿]`. Or you could define your own list, like for 0-key. + - Keys 2 through 9, just contain the possible letters. - `abcString` _(optional)_. A custom string to display in ABC mode. By default, the first three letters on 2-key are used (e.g. "ABC" or "АБВ"). Set this if the first letters of the alphabet are _not_ on 2-key, like in Hebrew, or if a different string makes more sense. - `hasUpperCase` _(optional)_ set to `no` when the language has no upper- and lowercase letters. For example: Arabic, Hebrew, East Asian languages, and so on. The default is `yes`. - `name` _(optional)_ is automatically generated and equals the native name of the language (e.g. "English", "Deutsch", "Українська"). However, sometimes, the automatically selected name may be ambiguous. For example, both Portuguese in Portugal and Brazil will default to "Português", so assigning "Português brasileiro" would make it clear it's the language used in Brazil. diff --git a/assets/languages/definitions/BrazilianPortuguese.yml b/assets/languages/definitions/BrazilianPortuguese.yml index 53d1e464..8bd51297 100644 --- a/assets/languages/definitions/BrazilianPortuguese.yml +++ b/assets/languages/definitions/BrazilianPortuguese.yml @@ -3,8 +3,8 @@ locale: pt-BR dictionaryFile: pt-BR-utf8.csv name: Português brasileiro layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION] # 1 - [a, b, c, ç, á, â, ã, à] # 2 - [d, e, f, é, ê, è] # 3 - [g, h, i, í] # 4 diff --git a/assets/languages/definitions/Bulgarian.yml b/assets/languages/definitions/Bulgarian.yml index 3b22414e..97194488 100644 --- a/assets/languages/definitions/Bulgarian.yml +++ b/assets/languages/definitions/Bulgarian.yml @@ -2,8 +2,8 @@ locale: bg-BG dictionaryFile: bg-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION_DE] # 1 - [а, б, в, г] # 2 - [д, е, ж, з] # 3 - [и, й, к, л, ѝ] # 4 diff --git a/assets/languages/definitions/Danish.yml b/assets/languages/definitions/Danish.yml index 7861468f..5288e537 100644 --- a/assets/languages/definitions/Danish.yml +++ b/assets/languages/definitions/Danish.yml @@ -2,8 +2,8 @@ locale: da-DK dictionaryFile: da-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION_FR] # 1 - [a, b, c, æ, å] # 2 - [d, e, f, é] # 3 - [g, h, i] # 4 diff --git a/assets/languages/definitions/Dutch.yml b/assets/languages/definitions/Dutch.yml index e64ae6a5..1db7d4e4 100644 --- a/assets/languages/definitions/Dutch.yml +++ b/assets/languages/definitions/Dutch.yml @@ -2,8 +2,8 @@ locale: nl-NL dictionaryFile: nl-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION] # 1 - [a, b, c, à, ä, ç] # 2 - [d, e, f, é, è, ê, ë] # 3 - [g, h, i, î, ï] # 4 diff --git a/assets/languages/definitions/English.yml b/assets/languages/definitions/English.yml index c5644254..aa792bfa 100644 --- a/assets/languages/definitions/English.yml +++ b/assets/languages/definitions/English.yml @@ -2,8 +2,8 @@ locale: en dictionaryFile: en-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION] # 1 - [a, b, c] # 2 - [d, e, f] # 3 - [g, h, i] # 4 diff --git a/assets/languages/definitions/Finnish.yml b/assets/languages/definitions/Finnish.yml index c84c0b38..75eb8625 100644 --- a/assets/languages/definitions/Finnish.yml +++ b/assets/languages/definitions/Finnish.yml @@ -2,8 +2,8 @@ locale: fi-FI dictionaryFile: fi-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION] # 1 - [a, b, c, ä, å] # 2 - [d, e, f] # 3 - [g, h, i] # 4 diff --git a/assets/languages/definitions/French.yml b/assets/languages/definitions/French.yml index af3fbdfb..09212501 100644 --- a/assets/languages/definitions/French.yml +++ b/assets/languages/definitions/French.yml @@ -2,8 +2,8 @@ locale: fr dictionaryFile: fr-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION_FR] # 1 - [a, b, c, à, â, æ, ç] # 2 - [d, e, f, é, è, ê, ë] # 3 - [g, h, i, î, ï] # 4 diff --git a/assets/languages/definitions/German.yml b/assets/languages/definitions/German.yml index 6cc4eb2b..2a5991aa 100644 --- a/assets/languages/definitions/German.yml +++ b/assets/languages/definitions/German.yml @@ -2,8 +2,8 @@ locale: de dictionaryFile: de-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION_DE] # 1 - [a, b, c, ä] # 2 - [d, e, f] # 3 - [g, h, i] # 4 diff --git a/assets/languages/definitions/Greek.yml b/assets/languages/definitions/Greek.yml index afd0003d..2ec41110 100644 --- a/assets/languages/definitions/Greek.yml +++ b/assets/languages/definitions/Greek.yml @@ -2,8 +2,8 @@ locale: el-GR dictionaryFile: gr-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION_FR] # 1 - [α, β, γ, ά] # 2 - [δ, ε, ζ, έ] # 3 - [η, θ, ι, ή, ί, ϊ, ΐ] # 4 diff --git a/assets/languages/definitions/Hebrew.yml b/assets/languages/definitions/Hebrew.yml index 950b0f97..17f36ab7 100644 --- a/assets/languages/definitions/Hebrew.yml +++ b/assets/languages/definitions/Hebrew.yml @@ -4,8 +4,8 @@ dictionaryFile: he-utf8.csv abcString: אבג hasUpperCase: no layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION] # 1 - [ד, ה, ו] # 2 - [א, ב, ג] # 3 - [מ, ם, נ, ן] # 4 diff --git a/assets/languages/definitions/Indonesian.yml b/assets/languages/definitions/Indonesian.yml index 218e8ded..416efe11 100644 --- a/assets/languages/definitions/Indonesian.yml +++ b/assets/languages/definitions/Indonesian.yml @@ -3,8 +3,8 @@ locale: in-ID dictionaryFile: id-utf8.csv name: Bahasa Indonesia layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION] # 1 - [a, b, c] # 2 - [d, e, f] # 3 - [g, h, i] # 4 diff --git a/assets/languages/definitions/Italian.yml b/assets/languages/definitions/Italian.yml index ee3c8cab..b4e24861 100644 --- a/assets/languages/definitions/Italian.yml +++ b/assets/languages/definitions/Italian.yml @@ -2,8 +2,8 @@ locale: it dictionaryFile: it-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION] # 1 - [a, b, c, à] # 2 - [d, e, f, é, è] # 3 - [g, h, i, ì, í, î] # 4 diff --git a/assets/languages/definitions/Norwegian.yml b/assets/languages/definitions/Norwegian.yml index 51f6c187..c8b886d8 100644 --- a/assets/languages/definitions/Norwegian.yml +++ b/assets/languages/definitions/Norwegian.yml @@ -2,8 +2,8 @@ locale: nb-NO dictionaryFile: nb-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION_FR] # 1 - [a, b, c, æ, å] # 2 - [d, e, f, é, è] # 3 - [g, h, i] # 4 diff --git a/assets/languages/definitions/Polish.yml b/assets/languages/definitions/Polish.yml index f11f5ff1..49f9d7ca 100644 --- a/assets/languages/definitions/Polish.yml +++ b/assets/languages/definitions/Polish.yml @@ -2,8 +2,8 @@ locale: pl-PL dictionaryFile: pl-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION_DE] # 1 - [a, b, c, ą, ć] # 2 - [d, e, f, ę] # 3 - [g, h, i] # 4 diff --git a/assets/languages/definitions/Russian.yml b/assets/languages/definitions/Russian.yml index 3b649e2f..e05f8ea9 100644 --- a/assets/languages/definitions/Russian.yml +++ b/assets/languages/definitions/Russian.yml @@ -2,8 +2,8 @@ locale: ru-RU dictionaryFile: ru-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION_FR] # 1 - [а, б, в, г] # 2 - [д, е, ё, ж, з] # 3 - [и, й, к, л] # 4 diff --git a/assets/languages/definitions/Spanish.yml b/assets/languages/definitions/Spanish.yml index e817e599..8c335e8e 100644 --- a/assets/languages/definitions/Spanish.yml +++ b/assets/languages/definitions/Spanish.yml @@ -2,8 +2,8 @@ locale: es-ES dictionaryFile: es-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT, ¡, ¿] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION_FR, ¡, ¿] # 1 - [a, b, c, á] # 2 - [d, e, f, é] # 3 - [g, h, i, í] # 4 diff --git a/assets/languages/definitions/Swedish.yml b/assets/languages/definitions/Swedish.yml index 9a498f71..38651ce0 100644 --- a/assets/languages/definitions/Swedish.yml +++ b/assets/languages/definitions/Swedish.yml @@ -2,8 +2,8 @@ locale: sv-SE dictionaryFile: sv-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION] # 1 - [a, b, c, å, ä] # 2 - [d, e, f, é] # 3 - [g, h, i] # 4 diff --git a/assets/languages/definitions/Ukrainian.yml b/assets/languages/definitions/Ukrainian.yml index 5531d3a6..01faa1dd 100644 --- a/assets/languages/definitions/Ukrainian.yml +++ b/assets/languages/definitions/Ukrainian.yml @@ -2,8 +2,8 @@ locale: uk-UA dictionaryFile: uk-utf8.csv layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION_FR] # 1 - [а, б, в, г, ґ] # 2 - [д, е, є, ж, з] # 3 - [и, і, ї, й, к, л] # 4 diff --git a/assets/languages/definitions/Yiddish.yml b/assets/languages/definitions/Yiddish.yml index f3eddf8a..65f7dddb 100644 --- a/assets/languages/definitions/Yiddish.yml +++ b/assets/languages/definitions/Yiddish.yml @@ -4,8 +4,8 @@ dictionaryFile: ji-utf8.csv abcString: אבג hasUpperCase: no layout: - - [DEFAULT] # 0 - - [DEFAULT] # 1 + - [SPECIAL] # 0 + - [PUNCTUATION] # 1 - [ד, ה, ו] # 2 - [א, ב, ג] # 3 - [מ, ם, נ, ן] # 4 diff --git a/src/io/github/sspanak/tt9/ime/modes/helpers/AutoSpace.java b/src/io/github/sspanak/tt9/ime/modes/helpers/AutoSpace.java index 5f3e4830..ba4598a4 100644 --- a/src/io/github/sspanak/tt9/ime/modes/helpers/AutoSpace.java +++ b/src/io/github/sspanak/tt9/ime/modes/helpers/AutoSpace.java @@ -82,6 +82,8 @@ public class AutoSpace { || previousChar == ')' || previousChar == ']' || previousChar == '%' + || previousChar == '»' + || previousChar == '“' || previousChars.endsWith(" -") || previousChars.endsWith(" /") ); diff --git a/src/io/github/sspanak/tt9/languages/Characters.java b/src/io/github/sspanak/tt9/languages/Characters.java index 6197de1b..be9cecfb 100644 --- a/src/io/github/sspanak/tt9/languages/Characters.java +++ b/src/io/github/sspanak/tt9/languages/Characters.java @@ -7,10 +7,18 @@ import java.util.ArrayList; import java.util.Arrays; public class Characters { - final public static ArrayList Sentence = new ArrayList<>(Arrays.asList( + final public static ArrayList PunctuationEnglish = new ArrayList<>(Arrays.asList( ",", ".", "-", "(", ")", "[", "]", "&", "~", "`", "'", ";", ":", "\"", "!", "?" )); + final public static ArrayList PunctuationFrench = new ArrayList<>(Arrays.asList( + ",", ".", "-", "«", "»", "(", ")", "[", "]", "&", "~", "`", "\"", "'", ";", ":", "!", "?" + )); + + final public static ArrayList PunctuationGerman = new ArrayList<>(Arrays.asList( + ",", ".", "-", "„", "“", "(", ")", "[", "]", "&", "~", "`", "'", ";", ":", "!", "?" + )); + final public static ArrayList Special = new ArrayList<>(Arrays.asList( " ", "\n", "@", "_", "#", "%", "$", "{", "}", "|", "^", "<", ">", "\\", "/", "=", "*", "+" )); diff --git a/src/io/github/sspanak/tt9/languages/Language.java b/src/io/github/sspanak/tt9/languages/Language.java index 05400d96..f524e859 100644 --- a/src/io/github/sspanak/tt9/languages/Language.java +++ b/src/io/github/sspanak/tt9/languages/Language.java @@ -70,18 +70,33 @@ public class Language { private static ArrayList keyCharsFromDefinition(int key, ArrayList definitionChars) { - final String defaultCharsPlaceholder = "DEFAULT"; - - if (key > 1 || !definitionChars.contains(defaultCharsPlaceholder)) { + if (key > 1) { return definitionChars; } + final String specialCharsPlaceholder = "SPECIAL"; + final String punctuationPlaceholder = "PUNCTUATION"; + final String frenchStylePlaceholder = punctuationPlaceholder + "_FR"; + final String germanStylePlaceholder = punctuationPlaceholder + "_DE"; + ArrayList keyChars = new ArrayList<>(); for (String defChar : definitionChars) { - if (defChar.equals(defaultCharsPlaceholder)) { - keyChars.addAll(key == 0 ? Characters.Special : Characters.Sentence); - } else { - keyChars.add(defChar); + switch (defChar) { + case specialCharsPlaceholder: + keyChars.addAll(Characters.Special); + break; + case punctuationPlaceholder: + keyChars.addAll(Characters.PunctuationEnglish); + break; + case frenchStylePlaceholder: + keyChars.addAll(Characters.PunctuationFrench); + break; + case germanStylePlaceholder: + keyChars.addAll(Characters.PunctuationGerman); + break; + default: + keyChars.add(defChar); + break; } }