Hello Guys
I am developing a dictionary application where users can search Arabic <-> Turkish. I'm getting the data from firebase, no problem here. In my algorithm, the user's keyboard language is selected when the user presses the search view. If this language is Turkish, the text entered by the user is listed as Turkish in the search view ( recycle view), sends it to the recycle view and is listed. If that language is Arabic, I list it as Arabic. By the way, you can think of the data I listed as key & value. The Turkish equivalent of each Arabic word is on the same line. So far the app is working fine for me because I am using my phone's default keyboard and I can get the keyboard language.
The problem starts here;
I can't get this keyboard language when user uses custom keyboards published in Play Store. I can't list it because I can't get the keyboard language. I opened a thread on Stackoverflow but was told that I can't access the language of these custom keyboards in any way. So, how can I sort by understanding whether the user is searching in Arabic or Turkish, without picking up the keyboard language or in any way asking the user in which language to search? Thanks in advance and good work.
CodePudding user response:
You will have to maintain a translation in your server, when user searches in one language the corresponding meaning in other language should also be searched, the corresponding meaning will be stored on the server(or on client).
CodePudding user response:
If you can't reliably get the keyboard's locale, that seems like a no-go for what you want to do. But even if someone's using a Turkish keyboard, that doesn't mean they're typing Turkish text, right? Since it basically covers the latin character set - they could even be typing in romanised Arabic! (I don't know how likely that is, but it's possible)
You might want to look into a library that detects languages - from a quick search there are a few, and ML-Kit is a Google library that people seem to recommend for it.
I think whatever you do, you probably want the user to be able to set their input language explicitly - give them the final say (and responsibility for ensuring it's correct!). Similar to how Google Translate does it - you can type and it can guess what language you're using (and it says something like (automatically detected) next to it) but the user gets to explicitly choose
edit since you really want this to be automatic (I'd really recommend giving the user control over this, just in case) could you do something like checking if the characters they've entered are Arabic script?
Doesn't help with romanised Arabic (I don't know if that's really used much at all!) - but if you can assume Arabic uses Arabic script, and Turkish is anything else (or you could do the same with the Turkish characters) then maybe you could take a guess just by comparing their input to a set of potential characters. There might even be a convenient Unicode grouping you can check, but I'm not sure off-hand. Might be worth looking into