I love the Froyo multiple languages keyboard feature! Its AWESOME, sliding a finger over the keyboard to change language .. Awesome!
If your specific dictionary is in there. Which it probably isnt, since there are only 6 dictionaries in the default keyboard. And Dutch isnt in there. Dutch is in several other keyboards, like the HTC one, but sadly there is no shared space where these dictionaries live, in the contrary, they all reside in the .apk that contains the keyboard.
By opening /system/app/LatinIME.apk (as found in CyanogenMod), we find out that the dictionaries are in the .apk under the res directory. While we’re there, someone mentioned the availability of more dicts might be a size issue, but I dont think so since they’re all quite moderate in size:
- raw-de: 739K
- raw-en: 822K
- raw-es: 768K
- raw-fr: 775K
- raw-it: 688K
- raw-sv: 911K
Also, the custom words are saved in a database at /data/data/com.android.inputmethod.latin/databases/auto_dict.db
Now, looking to add a dutch dictionary, I went looking in the AOSP. The LatinIME source is in ./packages/inputmethods/LatinIME and contains a ./packages/inputmethods/LatinIME/dictionaries directory. I expected to find the dictionary files there, but it only contains a sample.xml file. So no .xml dictionaries. The aforementioned res directory is at ./packages/inputmethods/LatinIME/java/res/ but contains none of the raw-lang directories.
The dictionaries do not appear to be part of the AOSP. I guess Google is not able to open source these?
While searching (the interwebs and IRC) I also discovered that a lot of other people (Issue 1827: add dictionaries for other locales (or make it easier for users to do so) – Im d.gen… in that thread) were looking to add their language to the code tree and that some people had solved the problem by just rolling a custom LatinIME (Softkeyboard). I dont like that option, however since I’d rather strengthen the default tree instead of splitting from it and updating the code after each AOSP update.
CyanogenMod however does have the dictionaries and so I checked out the CyanogenMod tree. it took me a while to find out where they were as I was expecting them to be in the paths I mentioned before, but no such luck. Apparently (and this makes sense,) the CM specific files are in the ./vendor/cyanogen directory, the binary dictionaries in
So. How to add new dictionaries to Android?
- Either in AOSP under packages/inputmethods/LatinIME/dictionaries/ as .xml files (preferable),
- under packages/inputmethods/LatinIME/java/res/ as binary files
- or if that turns out to be impossible for some reason, adding them to CM in the respective vendor/cyanogen/overlay/common/packages/inputmethods/LatinIME/ directories (so that at least CM has the extended languages).
The ideal situation however would be to split the dictionaries from the keyboards and put them somewhere where any application might use them; making it possible to install new dictionary packs (eg DutchDictionary.apk) from the market, thus solving the whole dictionary problem. Maybe by adding them in /data/data/com.android.inputmethod.latin/databases/ although there is probably a performance reason for them not being there in the first place?
Anyhow, in the mean while, we do need the dictionaries! So lets not wait for this and add the data to AOSP now 🙂
Im wondering though why the Softkeyboard people dont add their dictionaries to AOSP.. I do see the benefit of keeping it available in the market as a separate app, ie making it available to every android user instead of those “few” tinkerers running the latest AOSP (or mods based on it.)