fixed sorting of East Asian languages
This commit is contained in:
parent
24b853564c
commit
09c0a646dd
2 changed files with 22 additions and 9 deletions
|
|
@ -13,7 +13,7 @@ import io.github.sspanak.tt9.util.Text;
|
|||
import io.github.sspanak.tt9.util.chars.Characters;
|
||||
|
||||
|
||||
public class NaturalLanguage extends TranscribedLanguage implements Comparable<NaturalLanguage> {
|
||||
public class NaturalLanguage extends TranscribedLanguage {
|
||||
final public static String SPECIAL_CHAR_KEY = "0";
|
||||
final public static String PUNCTUATION_KEY = "1";
|
||||
final public static String PREFERRED_CHAR_SEQUENCE = "00";
|
||||
|
|
@ -143,8 +143,12 @@ public class NaturalLanguage extends TranscribedLanguage implements Comparable<N
|
|||
return id;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getSortingId() {
|
||||
if (isTranscribed) {
|
||||
return super.getSortingId();
|
||||
}
|
||||
|
||||
private String getSortingId() {
|
||||
if ("IN".equals(getLocale().getCountry()) && "en".equals(getLocale().getLanguage())) {
|
||||
return "hi";
|
||||
}
|
||||
|
|
@ -275,10 +279,4 @@ public class NaturalLanguage extends TranscribedLanguage implements Comparable<N
|
|||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(NaturalLanguage other) {
|
||||
return getSortingId().compareTo(other.getSortingId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ package io.github.sspanak.tt9.languages;
|
|||
|
||||
import io.github.sspanak.tt9.util.TextTools;
|
||||
|
||||
abstract class TranscribedLanguage extends Language {
|
||||
abstract class TranscribedLanguage extends Language implements Comparable<TranscribedLanguage> {
|
||||
|
||||
@Override
|
||||
public boolean isValidWord(String word) {
|
||||
|
|
@ -13,4 +13,19 @@ abstract class TranscribedLanguage extends Language {
|
|||
return (LanguageKind.isKorean(this) && TextTools.isHangul(word))
|
||||
|| (LanguageKind.isChinese(this) && TextTools.isChinese(word));
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* These are usually languages with special scripts, such as Chinese, Korean, etc. They can't
|
||||
* be sorted alphabetically so just put them at the end.
|
||||
*/
|
||||
protected String getSortingId() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public int compareTo(TranscribedLanguage other) {
|
||||
return getSortingId().compareTo(other.getSortingId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue