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

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