mirror of
https://github.com/Helium314/HeliBoard.git
synced 2025-04-24 00:26:22 +00:00
extend list of locales for which bigrams are used in contacts dictionary
This commit is contained in:
parent
efa2faf474
commit
b69ec39539
2 changed files with 12 additions and 3 deletions
|
@ -13,6 +13,7 @@ import android.provider.ContactsContract;
|
|||
import android.provider.ContactsContract.Contacts;
|
||||
import helium314.keyboard.latin.utils.Log;
|
||||
|
||||
import androidx.annotation.NonNull;
|
||||
import androidx.annotation.Nullable;
|
||||
|
||||
import com.android.inputmethod.latin.BinaryDictionary;
|
||||
|
@ -49,7 +50,7 @@ public class ContactsBinaryDictionary extends ExpandableBinaryDictionary
|
|||
reloadDictionaryIfRequired();
|
||||
}
|
||||
|
||||
public static ContactsBinaryDictionary getDictionary(final Context context, final Locale locale,
|
||||
public static ContactsBinaryDictionary getDictionary(final Context context, @NonNull final Locale locale,
|
||||
final File dictFile, final String dictNamePrefix, @Nullable final String account) {
|
||||
return new ContactsBinaryDictionary(context, locale, dictFile, dictNamePrefix + NAME);
|
||||
}
|
||||
|
|
|
@ -7,6 +7,7 @@
|
|||
package helium314.keyboard.latin;
|
||||
|
||||
import helium314.keyboard.latin.common.Constants;
|
||||
import helium314.keyboard.latin.utils.ScriptUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
|
@ -36,7 +37,14 @@ public class ContactsDictionaryUtils {
|
|||
* Returns true if the locale supports using first name and last name as bigrams.
|
||||
*/
|
||||
public static boolean useFirstLastBigramsForLocale(final Locale locale) {
|
||||
// TODO: Add firstname/lastname bigram rules for other languages.
|
||||
return locale != null && locale.getLanguage().equals(Locale.ENGLISH.getLanguage());
|
||||
// todo (later): incomplete, see https://en.wikipedia.org/wiki/Personal_name#Name_order
|
||||
return switch (ScriptUtils.script(locale)) {
|
||||
case ScriptUtils.SCRIPT_CYRILLIC -> true;
|
||||
case ScriptUtils.SCRIPT_LATIN -> switch (locale.getLanguage()) {
|
||||
case "hu", "ro", "vi" -> false;
|
||||
default -> true;
|
||||
};
|
||||
default -> false;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue