user964283
user964283

Reputation: 863

Get current language set on Android device

I have a edittext which the user enters some text into

Once they press the submit button I process the text they entered.

I need to apply different logic if they have entered English and any other language.

What's the best way to assess if its English they have entered?

1) Get the language of the keyboard? Is this possible. On my SE XPeria I can change the keyboard language and the device local still remains English

2) Analyse the string to check if its in English???

3) Worst case scenario I ask the user if they entered English

Upvotes: 0

Views: 1012

Answers (2)

Graham Smith
Graham Smith

Reputation: 25757

Another idea, that would be slower for the record, would be to use an online service such as Google translate or http://detectlanguage.com/ APIs. You could send a portion of the string off and then process the response to see what language was entered.

Upvotes: 1

Rajdeep Dua
Rajdeep Dua

Reputation: 11230

You can check using the Unicode of the characters entered. Refer to http://docs.oracle.com/javase/1.5.0/docs/api/java/lang/Character.UnicodeBlock.html

Upvotes: 1

Related Questions