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
|
|
@ -56,6 +56,7 @@ To support a new language one needs to:
|
||||||
- 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.
|
- 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.
|
- 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.
|
- `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.
|
||||||
|
- `currency` _(optional)_. A string representing the currency related to that language, for example: `₪`, `₩`, `﷼`, etc. The character will be displayed in position 3 between the factory currency characters.
|
||||||
- `hasSpaceBetweenWords` _(optional)_ set to `no` when the language does not use spaces between words. For example: Thai, Chinese, Japanese, Korean, and so on. The default is `yes`.
|
- `hasSpaceBetweenWords` _(optional)_ set to `no` when the language does not use spaces between words. For example: Thai, Chinese, Japanese, Korean, and so on. The default is `yes`.
|
||||||
- `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`.
|
- `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.
|
- `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.
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
locale: ar-JO
|
locale: ar-JO
|
||||||
|
currency: ﷼
|
||||||
dictionaryFile: ar-utf8.csv
|
dictionaryFile: ar-utf8.csv
|
||||||
abcString: أﺏﺕ
|
abcString: أﺏﺕ
|
||||||
hasUpperCase: no
|
hasUpperCase: no
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
locale: gu-IN
|
locale: gu-IN
|
||||||
|
currency: ૱
|
||||||
dictionaryFile: gu-utf8.csv
|
dictionaryFile: gu-utf8.csv
|
||||||
abcString: કખગ
|
abcString: કખગ
|
||||||
hasUpperCase: no
|
hasUpperCase: no
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
locale: iw-IL
|
locale: iw-IL
|
||||||
|
currency: ₪
|
||||||
dictionaryFile: he-utf8.csv
|
dictionaryFile: he-utf8.csv
|
||||||
abcString: אבג
|
abcString: אבג
|
||||||
hasUpperCase: no
|
hasUpperCase: no
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
locale: hi-IN
|
locale: hi-IN
|
||||||
|
currency: ₹
|
||||||
dictionaryFile: hi-utf8.csv
|
dictionaryFile: hi-utf8.csv
|
||||||
abcString: कखग
|
abcString: कखग
|
||||||
hasUpperCase: no
|
hasUpperCase: no
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
locale: ko-KR
|
locale: ko-KR
|
||||||
|
currency: ₩
|
||||||
dictionaryFile: ko-utf8.csv
|
dictionaryFile: ko-utf8.csv
|
||||||
hasUpperCase: no
|
hasUpperCase: no
|
||||||
layout: # only used for the virtual key labels
|
layout: # only used for the virtual key labels
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
locale: ru-RU
|
locale: ru-RU
|
||||||
|
currency: ₽
|
||||||
dictionaryFile: ru-utf8.csv
|
dictionaryFile: ru-utf8.csv
|
||||||
layout:
|
layout:
|
||||||
- [SPECIAL] # 0
|
- [SPECIAL] # 0
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
locale: th-TH
|
locale: th-TH
|
||||||
|
currency: ฿
|
||||||
dictionaryFile: th-utf8.csv
|
dictionaryFile: th-utf8.csv
|
||||||
abcString: กขค
|
abcString: กขค
|
||||||
hasSpaceBetweenWords: no
|
hasSpaceBetweenWords: no
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
locale: tr-TR
|
locale: tr-TR
|
||||||
|
currency: ₺
|
||||||
dictionaryFile: tr-utf8.csv
|
dictionaryFile: tr-utf8.csv
|
||||||
layout:
|
layout:
|
||||||
- [SPECIAL] # 0
|
- [SPECIAL] # 0
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
locale: uk-UA
|
locale: uk-UA
|
||||||
|
currency: ₴
|
||||||
dictionaryFile: uk-utf8.csv
|
dictionaryFile: uk-utf8.csv
|
||||||
layout:
|
layout:
|
||||||
- [SPECIAL] # 0
|
- [SPECIAL] # 0
|
||||||
|
|
|
||||||
|
|
@ -1,4 +1,5 @@
|
||||||
locale: vi-VN
|
locale: vi-VN
|
||||||
|
currency: ₫
|
||||||
dictionaryFile: vi-utf8.csv
|
dictionaryFile: vi-utf8.csv
|
||||||
layout:
|
layout:
|
||||||
- [SPECIAL] # 0
|
- [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.ime.helpers.TextField;
|
||||||
import io.github.sspanak.tt9.languages.Language;
|
import io.github.sspanak.tt9.languages.Language;
|
||||||
import io.github.sspanak.tt9.languages.LanguageKind;
|
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.preferences.settings.SettingsStore;
|
||||||
import io.github.sspanak.tt9.util.Text;
|
import io.github.sspanak.tt9.util.Text;
|
||||||
import io.github.sspanak.tt9.util.chars.Characters;
|
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> 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 static final Set<Character> NOT_FRENCH_NO_PRECEDING_SPACE_PUNCTUATION = Set.of(';', ':', '!', '?', '»');
|
||||||
|
|
||||||
|
private Language language;
|
||||||
private final SettingsStore settings;
|
private final SettingsStore settings;
|
||||||
|
|
||||||
private boolean isLanguageFrench;
|
private boolean isLanguageFrench;
|
||||||
|
|
@ -26,6 +28,7 @@ public class AutoSpace {
|
||||||
|
|
||||||
|
|
||||||
public AutoSpace(SettingsStore settingsStore) {
|
public AutoSpace(SettingsStore settingsStore) {
|
||||||
|
language = new NullLanguage();
|
||||||
settings = settingsStore;
|
settings = settingsStore;
|
||||||
isLanguageWithAlphabet = false;
|
isLanguageWithAlphabet = false;
|
||||||
isLanguageFrench = false;
|
isLanguageFrench = false;
|
||||||
|
|
@ -33,10 +36,11 @@ public class AutoSpace {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public AutoSpace setLanguage(Language language) {
|
public AutoSpace setLanguage(Language lang) {
|
||||||
isLanguageFrench = LanguageKind.isFrench(language);
|
language = language == null ? new NullLanguage() : lang;
|
||||||
isLanguageWithAlphabet = language != null && !language.isSyllabary();
|
isLanguageFrench = LanguageKind.isFrench(lang);
|
||||||
isLanguageWithSpaceBetweenWords = language != null && language.hasSpaceBetweenWords();
|
isLanguageWithAlphabet = !language.isSyllabary();
|
||||||
|
isLanguageWithSpaceBetweenWords = language.hasSpaceBetweenWords();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -112,7 +116,9 @@ public class AutoSpace {
|
||||||
|| (!Character.isDigit(penultimateChar) && previousChar == ':')
|
|| (!Character.isDigit(penultimateChar) && previousChar == ':')
|
||||||
|| (!Character.isDigit(penultimateChar) && previousChar == '.')
|
|| (!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;
|
locale = Locale.ROOT;
|
||||||
abcString = "emoji";
|
abcString = "emoji";
|
||||||
code = "emj";
|
code = "emj";
|
||||||
|
currency = "";
|
||||||
name = "Emoji";
|
name = "Emoji";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -11,6 +11,7 @@ abstract public class Language {
|
||||||
protected int id;
|
protected int id;
|
||||||
protected String abcString;
|
protected String abcString;
|
||||||
protected String code;
|
protected String code;
|
||||||
|
protected String currency;
|
||||||
protected String dictionaryFile;
|
protected String dictionaryFile;
|
||||||
protected Locale locale = Locale.ROOT;
|
protected Locale locale = Locale.ROOT;
|
||||||
protected String name;
|
protected String name;
|
||||||
|
|
@ -31,6 +32,10 @@ abstract public class Language {
|
||||||
return code;
|
return code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@NonNull public String getCurrency() {
|
||||||
|
return currency;
|
||||||
|
}
|
||||||
|
|
||||||
@NonNull final public String getDictionaryFile() {
|
@NonNull final public String getDictionaryFile() {
|
||||||
return dictionaryFile;
|
return dictionaryFile;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,7 @@ public class LanguageDefinition extends AssetFile {
|
||||||
private static final String definitionsDir = languagesDir + "/definitions";
|
private static final String definitionsDir = languagesDir + "/definitions";
|
||||||
|
|
||||||
public String abcString = "";
|
public String abcString = "";
|
||||||
|
public String currency = "";
|
||||||
public String dictionaryFile = "";
|
public String dictionaryFile = "";
|
||||||
public boolean hasSpaceBetweenWords = true;
|
public boolean hasSpaceBetweenWords = true;
|
||||||
public boolean hasUpperCase = true;
|
public boolean hasUpperCase = true;
|
||||||
|
|
@ -90,6 +91,7 @@ public class LanguageDefinition extends AssetFile {
|
||||||
|
|
||||||
private void parse(ArrayList<String> yaml) {
|
private void parse(ArrayList<String> yaml) {
|
||||||
abcString = getPropertyFromYaml(yaml, "abcString", abcString);
|
abcString = getPropertyFromYaml(yaml, "abcString", abcString);
|
||||||
|
currency = getPropertyFromYaml(yaml, "currency", currency);
|
||||||
|
|
||||||
dictionaryFile = getPropertyFromYaml(yaml, "dictionaryFile", dictionaryFile);
|
dictionaryFile = getPropertyFromYaml(yaml, "dictionaryFile", dictionaryFile);
|
||||||
if (dictionaryFile != null) {
|
if (dictionaryFile != null) {
|
||||||
|
|
@ -102,8 +104,6 @@ public class LanguageDefinition extends AssetFile {
|
||||||
layout = getLayoutFromYaml(yaml);
|
layout = getLayoutFromYaml(yaml);
|
||||||
locale = getPropertyFromYaml(yaml, "locale", locale);
|
locale = getPropertyFromYaml(yaml, "locale", locale);
|
||||||
name = getPropertyFromYaml(yaml, "name", name);
|
name = getPropertyFromYaml(yaml, "name", name);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ public class NaturalLanguage extends Language implements Comparable<NaturalLangu
|
||||||
|
|
||||||
NaturalLanguage lang = new NaturalLanguage();
|
NaturalLanguage lang = new NaturalLanguage();
|
||||||
lang.abcString = definition.abcString.isEmpty() ? null : definition.abcString;
|
lang.abcString = definition.abcString.isEmpty() ? null : definition.abcString;
|
||||||
|
lang.currency = definition.currency;
|
||||||
lang.dictionaryFile = definition.getDictionaryFile();
|
lang.dictionaryFile = definition.getDictionaryFile();
|
||||||
lang.hasSpaceBetweenWords = definition.hasSpaceBetweenWords;
|
lang.hasSpaceBetweenWords = definition.hasSpaceBetweenWords;
|
||||||
lang.hasUpperCase = definition.hasUpperCase;
|
lang.hasUpperCase = definition.hasUpperCase;
|
||||||
|
|
@ -213,6 +214,7 @@ public class NaturalLanguage extends Language implements Comparable<NaturalLangu
|
||||||
chars = new ArrayList<>();
|
chars = new ArrayList<>();
|
||||||
} else if (characterGroup == 1) {
|
} else if (characterGroup == 1) {
|
||||||
chars = new ArrayList<>(Characters.Currency);
|
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 class NullLanguage extends Language {
|
||||||
public NullLanguage() {
|
public NullLanguage() {
|
||||||
locale = Locale.ROOT;
|
|
||||||
name = "Nulla Lingua";
|
|
||||||
abcString = "ABC";
|
abcString = "ABC";
|
||||||
code = "";
|
code = "";
|
||||||
|
currency = "";
|
||||||
dictionaryFile = "";
|
dictionaryFile = "";
|
||||||
hasUpperCase = false;
|
hasUpperCase = false;
|
||||||
|
locale = Locale.ROOT;
|
||||||
|
name = "Nulla Lingua";
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
|
|
||||||
|
|
@ -3,9 +3,11 @@ package io.github.sspanak.tt9.util.chars;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
|
import io.github.sspanak.tt9.languages.Language;
|
||||||
|
|
||||||
public class Characters extends Emoji {
|
public class Characters extends Emoji {
|
||||||
final public static ArrayList<String> Currency = new ArrayList<>(Arrays.asList(
|
final public static ArrayList<String> Currency = new ArrayList<>(Arrays.asList(
|
||||||
"$", "€", "₹", "₿", "₩", "¢", "¤", "₺", "₱", "¥", "₽", "£"
|
"$", "€", "₿", "¢", "¤", "₱", "¥", "£"
|
||||||
));
|
));
|
||||||
|
|
||||||
final public static ArrayList<String> Special = 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;
|
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 (
|
if (
|
||||||
rawLine.matches("^[a-zA-Z].*")
|
rawLine.matches("^[a-zA-Z].*")
|
||||||
&& !rawLine.startsWith("abcString")
|
&& !rawLine.startsWith("abcString")
|
||||||
|
&& !rawLine.startsWith("currency")
|
||||||
&& !rawLine.startsWith("dictionaryFile")
|
&& !rawLine.startsWith("dictionaryFile")
|
||||||
&& !rawLine.startsWith("hasSpaceBetweenWords")
|
&& !rawLine.startsWith("hasSpaceBetweenWords")
|
||||||
&& !rawLine.startsWith("hasUpperCase")
|
&& !rawLine.startsWith("hasUpperCase")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue