Skip to content
This repository has been archived by the owner on Oct 15, 2022. It is now read-only.

Fix non-default locale recognition on Android #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public void onMethodCall(MethodCall call, Result result) {
result.success(true);
break;
case "speech.listen":
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, getLocale(call.arguments.toString()));
recognizerIntent.putExtra(RecognizerIntent.EXTRA_LANGUAGE, getAndroidLocaleCode(call.arguments.toString()));
speech.startListening(recognizerIntent);
result.success(true);
break;
Expand All @@ -87,9 +87,8 @@ public void onMethodCall(MethodCall call, Result result) {
}
}

private Locale getLocale(String code) {
String[] localeParts = code.split("_");
return new Locale(localeParts[0], localeParts[1]);
private String getAndroidLocaleCode(String code) {
return code.replace("_", "-");
}

@Override
Expand Down