1
0
Fork 0

Proper quotation marks in all languages instead of default US ones (#297)

* proper quotation marks in all languages instead of default US ones

* auto-space after French and German quotation marks
This commit is contained in:
Dimo Karaivanov 2023-07-04 11:12:21 +03:00 committed by GitHub
parent 98df955ed3
commit dc0468ffeb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
23 changed files with 75 additions and 47 deletions

View file

@ -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.

View file

@ -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

View file

@ -2,8 +2,8 @@
locale: bg-BG
dictionaryFile: bg-utf8.csv
layout:
- [DEFAULT] # 0
- [DEFAULT] # 1
- [SPECIAL] # 0
- [PUNCTUATION_DE] # 1
- [а, б, в, г] # 2
- [д, е, ж, з] # 3
- [и, й, к, л, ѝ] # 4

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -2,8 +2,8 @@
locale: el-GR
dictionaryFile: gr-utf8.csv
layout:
- [DEFAULT] # 0
- [DEFAULT] # 1
- [SPECIAL] # 0
- [PUNCTUATION_FR] # 1
- [α, β, γ, ά] # 2
- [δ, ε, ζ, έ] # 3
- [η, θ, ι, ή, ί, ϊ, ΐ] # 4

View file

@ -4,8 +4,8 @@ dictionaryFile: he-utf8.csv
abcString: אבג
hasUpperCase: no
layout:
- [DEFAULT] # 0
- [DEFAULT] # 1
- [SPECIAL] # 0
- [PUNCTUATION] # 1
- [ד, ה, ו] # 2
- [א, ב, ג] # 3
- [מ, ם, נ, ן] # 4

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -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

View file

@ -2,8 +2,8 @@
locale: ru-RU
dictionaryFile: ru-utf8.csv
layout:
- [DEFAULT] # 0
- [DEFAULT] # 1
- [SPECIAL] # 0
- [PUNCTUATION_FR] # 1
- [а, б, в, г] # 2
- [д, е, ё, ж, з] # 3
- [и, й, к, л] # 4

View file

@ -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

View file

@ -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

View file

@ -2,8 +2,8 @@
locale: uk-UA
dictionaryFile: uk-utf8.csv
layout:
- [DEFAULT] # 0
- [DEFAULT] # 1
- [SPECIAL] # 0
- [PUNCTUATION_FR] # 1
- [а, б, в, г, ґ] # 2
- [д, е, є, ж, з] # 3
- [и, і, ї, й, к, л] # 4

View file

@ -4,8 +4,8 @@ dictionaryFile: ji-utf8.csv
abcString: אבג
hasUpperCase: no
layout:
- [DEFAULT] # 0
- [DEFAULT] # 1
- [SPECIAL] # 0
- [PUNCTUATION] # 1
- [ד, ה, ו] # 2
- [א, ב, ג] # 3
- [מ, ם, נ, ן] # 4

View file

@ -82,6 +82,8 @@ public class AutoSpace {
|| previousChar == ')'
|| previousChar == ']'
|| previousChar == '%'
|| previousChar == '»'
|| previousChar == '“'
|| previousChars.endsWith(" -")
|| previousChars.endsWith(" /")
);

View file

@ -7,10 +7,18 @@ import java.util.ArrayList;
import java.util.Arrays;
public class Characters {
final public static ArrayList<String> Sentence = new ArrayList<>(Arrays.asList(
final public static ArrayList<String> PunctuationEnglish = new ArrayList<>(Arrays.asList(
",", ".", "-", "(", ")", "[", "]", "&", "~", "`", "'", ";", ":", "\"", "!", "?"
));
final public static ArrayList<String> PunctuationFrench = new ArrayList<>(Arrays.asList(
",", ".", "-", "«", "»", "(", ")", "[", "]", "&", "~", "`", "\"", "'", ";", ":", "!", "?"
));
final public static ArrayList<String> PunctuationGerman = new ArrayList<>(Arrays.asList(
",", ".", "-", "", "", "(", ")", "[", "]", "&", "~", "`", "'", ";", ":", "!", "?"
));
final public static ArrayList<String> Special = new ArrayList<>(Arrays.asList(
" ", "\n", "@", "_", "#", "%", "$", "{", "}", "|", "^", "<", ">", "\\", "/", "=", "*", "+"
));

View file

@ -70,18 +70,33 @@ public class Language {
private static ArrayList<String> keyCharsFromDefinition(int key, ArrayList<String> 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<String> 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;
}
}