mirror of
https://github.com/M66B/FairEmail.git
synced 2026-03-31 14:17:03 +02:00
cld3 binding
This commit is contained in:
@@ -41,11 +41,23 @@ import java.util.Locale;
|
||||
import java.util.Set;
|
||||
|
||||
public class TextHelper {
|
||||
static {
|
||||
System.loadLibrary("fairemail");
|
||||
}
|
||||
|
||||
private static native String jni_language(byte[] octets);
|
||||
|
||||
static Locale detectLanguage(Context context, String text) {
|
||||
// Why not ML kit? https://developers.google.com/ml-kit/terms
|
||||
if (TextUtils.isEmpty(text))
|
||||
return null;
|
||||
|
||||
if (BuildConfig.DEBUG) {
|
||||
// https://github.com/google/cld3
|
||||
String lang = jni_language(text.getBytes());
|
||||
return Locale.forLanguageTag(lang);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.Q)
|
||||
return null;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user