added support for a currency character in the language definitions and added some more local currencies
This commit is contained in:
parent
5c1b3b532b
commit
ae619e1f0f
19 changed files with 43 additions and 10 deletions
|
|
@ -1,4 +1,5 @@
|
|||
locale: ar-JO
|
||||
currency: ﷼
|
||||
dictionaryFile: ar-utf8.csv
|
||||
abcString: أﺏﺕ
|
||||
hasUpperCase: no
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
locale: gu-IN
|
||||
currency: ૱
|
||||
dictionaryFile: gu-utf8.csv
|
||||
abcString: કખગ
|
||||
hasUpperCase: no
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
locale: iw-IL
|
||||
currency: ₪
|
||||
dictionaryFile: he-utf8.csv
|
||||
abcString: אבג
|
||||
hasUpperCase: no
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
locale: hi-IN
|
||||
currency: ₹
|
||||
dictionaryFile: hi-utf8.csv
|
||||
abcString: कखग
|
||||
hasUpperCase: no
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
locale: ko-KR
|
||||
currency: ₩
|
||||
dictionaryFile: ko-utf8.csv
|
||||
hasUpperCase: no
|
||||
layout: # only used for the virtual key labels
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
locale: ru-RU
|
||||
currency: ₽
|
||||
dictionaryFile: ru-utf8.csv
|
||||
layout:
|
||||
- [SPECIAL] # 0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
locale: th-TH
|
||||
currency: ฿
|
||||
dictionaryFile: th-utf8.csv
|
||||
abcString: กขค
|
||||
hasSpaceBetweenWords: no
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
locale: tr-TR
|
||||
currency: ₺
|
||||
dictionaryFile: tr-utf8.csv
|
||||
layout:
|
||||
- [SPECIAL] # 0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
locale: uk-UA
|
||||
currency: ₴
|
||||
dictionaryFile: uk-utf8.csv
|
||||
layout:
|
||||
- [SPECIAL] # 0
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
locale: vi-VN
|
||||
currency: ₫
|
||||
dictionaryFile: vi-utf8.csv
|
||||
layout:
|
||||
- [SPECIAL] # 0
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import io.github.sspanak.tt9.hacks.InputType;
|
|||
import io.github.sspanak.tt9.ime.helpers.TextField;
|
||||
import io.github.sspanak.tt9.languages.Language;
|
||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
||||
import io.github.sspanak.tt9.languages.NullLanguage;
|
||||
import io.github.sspanak.tt9.preferences.settings.SettingsStore;
|
||||
import io.github.sspanak.tt9.util.Text;
|
||||
import io.github.sspanak.tt9.util.chars.Characters;
|
||||
|
|
@ -18,6 +19,7 @@ public class AutoSpace {
|
|||
private static final Set<Character> NO_PRECEDING_SPACE_PUNCTUATION = Set.of('.', ',', ')', '\'', '@', '“', '؟', Characters.GR_QUESTION_MARK.charAt(0));
|
||||
private static final Set<Character> NOT_FRENCH_NO_PRECEDING_SPACE_PUNCTUATION = Set.of(';', ':', '!', '?', '»');
|
||||
|
||||
private Language language;
|
||||
private final SettingsStore settings;
|
||||
|
||||
private boolean isLanguageFrench;
|
||||
|
|
@ -26,6 +28,7 @@ public class AutoSpace {
|
|||
|
||||
|
||||
public AutoSpace(SettingsStore settingsStore) {
|
||||
language = new NullLanguage();
|
||||
settings = settingsStore;
|
||||
isLanguageWithAlphabet = false;
|
||||
isLanguageFrench = false;
|
||||
|
|
@ -33,10 +36,11 @@ public class AutoSpace {
|
|||
}
|
||||
|
||||
|
||||
public AutoSpace setLanguage(Language language) {
|
||||
isLanguageFrench = LanguageKind.isFrench(language);
|
||||
isLanguageWithAlphabet = language != null && !language.isSyllabary();
|
||||
isLanguageWithSpaceBetweenWords = language != null && language.hasSpaceBetweenWords();
|
||||
public AutoSpace setLanguage(Language lang) {
|
||||
language = language == null ? new NullLanguage() : lang;
|
||||
isLanguageFrench = LanguageKind.isFrench(lang);
|
||||
isLanguageWithAlphabet = !language.isSyllabary();
|
||||
isLanguageWithSpaceBetweenWords = language.hasSpaceBetweenWords();
|
||||
return this;
|
||||
}
|
||||
|
||||
|
|
@ -112,7 +116,9 @@ public class AutoSpace {
|
|||
|| (!Character.isDigit(penultimateChar) && previousChar == ':')
|
||||
|| (!Character.isDigit(penultimateChar) && previousChar == '.')
|
||||
|| (!Character.isDigit(penultimateChar) && previousChar == ',')
|
||||
|| (Character.isDigit(penultimateChar) && Characters.Currency.contains(String.valueOf(previousChar)))
|
||||
|| (
|
||||
Character.isDigit(penultimateChar) && Characters.isCurrency(language, String.valueOf(previousChar))
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ public class EmojiLanguage extends Language {
|
|||
locale = Locale.ROOT;
|
||||
abcString = "emoji";
|
||||
code = "emj";
|
||||
currency = "";
|
||||
name = "Emoji";
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@ abstract public class Language {
|
|||
protected int id;
|
||||
protected String abcString;
|
||||
protected String code;
|
||||
protected String currency;
|
||||
protected String dictionaryFile;
|
||||
protected Locale locale = Locale.ROOT;
|
||||
protected String name;
|
||||
|
|
@ -31,6 +32,10 @@ abstract public class Language {
|
|||
return code;
|
||||
}
|
||||
|
||||
@NonNull public String getCurrency() {
|
||||
return currency;
|
||||
}
|
||||
|
||||
@NonNull final public String getDictionaryFile() {
|
||||
return dictionaryFile;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ public class LanguageDefinition extends AssetFile {
|
|||
private static final String definitionsDir = languagesDir + "/definitions";
|
||||
|
||||
public String abcString = "";
|
||||
public String currency = "";
|
||||
public String dictionaryFile = "";
|
||||
public boolean hasSpaceBetweenWords = true;
|
||||
public boolean hasUpperCase = true;
|
||||
|
|
@ -90,6 +91,7 @@ public class LanguageDefinition extends AssetFile {
|
|||
|
||||
private void parse(ArrayList<String> yaml) {
|
||||
abcString = getPropertyFromYaml(yaml, "abcString", abcString);
|
||||
currency = getPropertyFromYaml(yaml, "currency", currency);
|
||||
|
||||
dictionaryFile = getPropertyFromYaml(yaml, "dictionaryFile", dictionaryFile);
|
||||
if (dictionaryFile != null) {
|
||||
|
|
@ -102,8 +104,6 @@ public class LanguageDefinition extends AssetFile {
|
|||
layout = getLayoutFromYaml(yaml);
|
||||
locale = getPropertyFromYaml(yaml, "locale", locale);
|
||||
name = getPropertyFromYaml(yaml, "name", name);
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -31,6 +31,7 @@ public class NaturalLanguage extends Language implements Comparable<NaturalLangu
|
|||
|
||||
NaturalLanguage lang = new NaturalLanguage();
|
||||
lang.abcString = definition.abcString.isEmpty() ? null : definition.abcString;
|
||||
lang.currency = definition.currency;
|
||||
lang.dictionaryFile = definition.getDictionaryFile();
|
||||
lang.hasSpaceBetweenWords = definition.hasSpaceBetweenWords;
|
||||
lang.hasUpperCase = definition.hasUpperCase;
|
||||
|
|
@ -213,6 +214,7 @@ public class NaturalLanguage extends Language implements Comparable<NaturalLangu
|
|||
chars = new ArrayList<>();
|
||||
} else if (characterGroup == 1) {
|
||||
chars = new ArrayList<>(Characters.Currency);
|
||||
if (!currency.isEmpty()) chars.add(2, currency);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -7,12 +7,13 @@ import java.util.Locale;
|
|||
|
||||
public class NullLanguage extends Language {
|
||||
public NullLanguage() {
|
||||
locale = Locale.ROOT;
|
||||
name = "Nulla Lingua";
|
||||
abcString = "ABC";
|
||||
code = "";
|
||||
currency = "";
|
||||
dictionaryFile = "";
|
||||
hasUpperCase = false;
|
||||
locale = Locale.ROOT;
|
||||
name = "Nulla Lingua";
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
|
|
|||
|
|
@ -3,9 +3,11 @@ package io.github.sspanak.tt9.util.chars;
|
|||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
import io.github.sspanak.tt9.languages.Language;
|
||||
|
||||
public class Characters extends Emoji {
|
||||
final public static ArrayList<String> Currency = new ArrayList<>(Arrays.asList(
|
||||
"$", "€", "₹", "₿", "₩", "¢", "¤", "₺", "₱", "¥", "₽", "£"
|
||||
"$", "€", "₿", "¢", "¤", "₱", "¥", "£"
|
||||
));
|
||||
|
||||
final public static ArrayList<String> Special = new ArrayList<>(Arrays.asList(
|
||||
|
|
@ -40,4 +42,8 @@ public class Characters extends Emoji {
|
|||
}
|
||||
return keyCharacters;
|
||||
}
|
||||
|
||||
public static boolean isCurrency(Language language, String c) {
|
||||
return Currency.contains(c) || (language != null && language.getCurrency().equals(c));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -62,6 +62,7 @@ ext.parseLanguageDefintion = { File languageFile, String dictionariesDir ->
|
|||
if (
|
||||
rawLine.matches("^[a-zA-Z].*")
|
||||
&& !rawLine.startsWith("abcString")
|
||||
&& !rawLine.startsWith("currency")
|
||||
&& !rawLine.startsWith("dictionaryFile")
|
||||
&& !rawLine.startsWith("hasSpaceBetweenWords")
|
||||
&& !rawLine.startsWith("hasUpperCase")
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue