Must display the virtual keyboard in alphabetical order in all locales
Closed, ResolvedPublic

Description

In several activities we display a virtual keyboard (gletters, hangman, ...).

In some 'complex' locale like Norwegian the sort is not correct. We must improve the sort to make it locale aware instead of just ascii or
let the translator provide the keyboard letter order.

bcoudoin created this task.Feb 5 2016, 11:17 AM

Reference from the mailing list

In the ‘Simple Letters’ activity, using the Norwegian Nynorsk (nn)
translation, the letters are listed as:

abc…xyzåæø

The last three letters are in the wrong order; they should be æøå. They
are listed in the correct order in
the ./gletters/resource/default-nn.json file, so it looks like there is
some reordering going on. I think just using the character order listed
in the .json files is the best solution.

corresponding IRC logs:

(04:28:10 PM) #gcompris: The topic for #gcompris is: Help us fund the new graphics for GCompris: http://igg.me/at/gcompris-unified-graphics
(04:28:10 PM) #gcompris: Topic for #gcompris set by bdoin!~bdoin@82.228.70.121 at 06:19:46 PM on 12/03/2014
(04:28:32 PM) JohnnyJ: huftis: hi
(04:28:43 PM) JohnnyJ: in your mail you're talking about the virtual keyboard ?
(04:32:59 PM) crucerucalin [~calin@p22.eregie.pub.ro] entered the room.
(04:53:42 PM) gandhi_m: JohnnyJ,huftis: yeah probably because we use a simple Array.sort() on the letter list
(04:54:01 PM) gandhi_m: using String.localeCompare instead gives me the following for nn:
(04:54:05 PM) JohnnyJ: hi
(04:54:07 PM) gandhi_m: qml: before: ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z","æ","ø","å"]
(04:54:07 PM) gandhi_m: qml: after: ["a","å","æ","b","c","d","e","f","g","h","i","j","k","l","m","n","o","ø","p","q","r","s","t","u","v","w","x","y","z"]
(04:54:11 PM) JohnnyJ: I found : http://forums.htmlhelp.com/lofiversion/index.php/t762.html
(04:54:27 PM) gandhi_m: does this seem correct to you, huftis?
(04:54:46 PM) JohnnyJ: in swedish the order is not the same as in norwegian and danish for these letters
(04:55:27 PM) huftis: No, the correct order should be abc…xyzæøå.
(04:56:36 PM) huftis: Danish should be the same order, but Swedish uses a different order.
(04:57:37 PM) huftis: If we just use the order in the .json file, everything should be fine. Then it’s the translator’s responsibility to choose the correct order.
(05:01:43 PM) gandhi_m: ok, I see, right now it would be a problem for wordsgame though, which generates the letters for the keyboard from whole words passed in the json-files, which are definitely not sorted alphabetically
(05:02:15 PM) gandhi_m: would be nice to have a locle aware sorting in place to cover both, gletters and wordsgame
(05:08:29 PM) huftis: I actually found the wordsgame keyboard quite confusing.
(05:08:57 PM) huftis: It seemed to contain all the letters of the alphabet, but (for example) q and c was missing.
(05:09:36 PM) JohnnyJ: does the level have words with these letters ?
(05:09:39 PM) huftis: Wouldn’t it be better (less confusing) to always display a complete alphabet?
(05:10:09 PM) huftis: JohnnyJ: No, that’s the reason the letters are missing. But I find it confusing.
(05:10:38 PM) huftis: And the letters ending up in different positions depending on the level is also confusing.
(05:10:56 PM) huftis: It makes the game more difficult than it needs to be, IMHO.
(05:11:01 PM) demm [~quassel@h129.36.117.75.dynamic.ip.windstream.net] entered the room.
(05:13:36 PM) JohnnyJ: gandhi_m: playing with String.localeCompare for the strings can help? console.log('ä'.localeCompare('z', 'sv')); // a positive value: in Swedish, ä sorts after z
(05:21:17 PM) gandhi_m: JohnnyJ, but console.log('æ'.localeCompare('z', 'nn')); shows a negative, which according to huftis is wrong
(05:22:52 PM) gandhi_m: huftis, good point
(05:23:36 PM) gandhi_m: maybe we should reconsider how to generate it for wordsgame
(05:24:23 PM) gandhi_m: for gletters IMHO it might be easier this way because you start with a smaller keyboard, at the beginning, when there are less letters
(05:26:28 PM) gandhi_m: we could also think about always presenting a complete qwerty-(or-whatever-it-is-in-your-layout)-layout
(05:28:01 PM) huftis: Yes, a complete QWERTY-like keyboard (with/without number keys) would be best. KTouch has localised keyboard layouts, IIRC.
(05:29:36 PM) huftis: Perhaps even darken the keys that’s not needed, like this? https://www.kde.org/images/screenshots/ktouch.png
(05:30:23 PM) huftis: At least in earlier levels, this could make the levels easier. And in later / more difficult levels all keys can be shown as enabled.
(05:31:00 PM) gandhi_m: good to know about ktouch, looks nice, indeed
(05:32:14 PM) gandhi_m: though in terms of the task (learn using the keyboard) on mobile devices it might also be suitable to use the (android) system keyboard
(05:32:44 PM) gandhi_m: ( ... which in the beginning was not easily doable with qtquick on android)
(05:33:18 PM) ***gandhi_m will have a look at ktouch
(05:33:22 PM) huftis: gandhi_m: Yes, using the Android system keyboard would be the most useful/educational.
(05:33:43 PM) huftis: Regarding Ktouch, here’s a more recent screenshot: https://edu.kde.org/images/screenshots/ktouch.png
(05:34:27 PM) huftis: Looks like it has seen several improvements over the years. Here’s a *really* old screenshot: https://fsfe.org/activities/education/tgs/img/ktouch.en.png
(05:34:52 PM) gandhi_m: hehe, right
(05:35:43 PM) JohnnyJ: http://blog.qt.digia.com/blog/2014/07/03/qt-virtual-keyboard-1-1/ but it's for enterprise...
(05:36:30 PM) gandhi_m: yeah, saw this one, JohnnyJ, looks *really* fancy! iirc can be styled, also
(05:36:42 PM) bdoin [~bdoin@2a01:e35:2e44:6790:4da:b802:8c31:1d24] entered the room.
(05:36:42 PM) #gcompris: mode (+o bdoin) by ChanServ
(05:37:25 PM) JohnnyJ: is it possible to do a "fake" TextInput/TextField that displays the android keyboard ?
(05:38:17 PM) gandhi_m: ~/git/ktouch/data/keyboardlayouts
(05:38:24 PM) gandhi_m: ^^ there they are
(05:39:41 PM) gandhi_m: JohnnyJ, yes, maybe, we did it for the composed keys already, you remember?
(05:39:51 PM) JohnnyJ: yes
(06:16:45 PM) anaselli [~quassel@mandriva/developer/kde/anaselli] entered the room.
(06:39:44 PM) pratik [~pratik@14.139.122.114] entered the room.
(06:46:07 PM) gandhi_m: JohnnyJ, huftis for the localeCompare: it works as huftis expected using a C++ wrapper around QCollator.compare()
(06:47:23 PM) JohnnyJ: good
(06:53:27 PM) gandhi_m: I think we can add a QApplicationInfo::localeCompare() which uses directly our currently active locale, a helper we might also need in other places at some time
(07:13:25 PM) gandhi_m: damn, that was on Linux, on android it does not work:
(07:13:25 PM) gandhi_m: W/Qt      (31586): (null):0 ((null)): Only default locale supported with the posix collation implementation
(07:18:29 PM) pratik: I am getting this error http://pastebin.com/kRsANE9x when I opened CMakeLists.txt in QTCreator what should i do?
(07:19:04 PM) JohnnyJ: you need to install a Qt with a higher version
(07:19:29 PM) JohnnyJ: yours is 5.2.1 and GCompris needs 5.3.0 minimum
(07:19:43 PM) pratik: ok
(07:20:25 PM) JohnnyJ: http://www.qt.io/download/
(07:20:41 PM) JohnnyJ: if you want to compile for android, take the for android version
(07:21:08 PM) JohnnyJ: http://www.qt.io/download-open-source/#
(07:21:23 PM) JohnnyJ: gandhi_m: not fun...
(07:21:34 PM) pratik left the room (quit: Read error: Connection reset by peer).
(07:21:56 PM) pratik [~pratik@14.139.122.114] entered the room.
(07:22:28 PM) JohnnyJ: gandhi_m: as it's "minor", we can maybe let as this for this version and try with an Input widget for next ?
(07:31:52 PM) bdoin: hi all, not sure what you are talking about, can I help?
(07:32:13 PM) JohnnyJ: with gandhi_m and huftis about the keyboard layout for norwegian
(07:32:39 PM) JohnnyJ: and pratik is someone who would like to contribute
(07:32:54 PM) JohnnyJ: I pointed him to the wiki and your github
(07:33:25 PM) bdoin: I got a mail from huftis about a keyboard issue but not yet looked at it
(07:34:06 PM) gandhi_m: Hi bdoin, history fyi: http://pastebin.com/atyczCjQ
(07:34:07 PM) bdoin: pratik: welcome on GCompris
(07:35:10 PM) gandhi_m: JohnnyJ, yes, you're right, the Android port is sometimes frustrating, will write up a bug report ...
(07:37:31 PM) bdoin: got the point for the keyboard issue. not sure what to do.
(07:38:03 PM) pratik: thank you
(07:39:04 PM) JohnnyJ: btw, using the android keyboard won't help if users want to play with keyboard on Desktop (not sure if there are legit cases?)
(07:42:11 PM) JohnnyJ: i mean, having our own keyboard make it platform independent
(07:42:26 PM) bdoin: yes there are use cases. children on linux with a touch screen
(07:42:58 PM) pratik left the room (quit: Quit: Leaving).
(07:45:03 PM) bdoin: I am tempted by the real ktouch localized keyboards but I see it for activities targeting older children. In this activity we are not teaching typing but reading and thus the alphabetical order seems more appropriate
(07:47:10 PM) bdoin: maybe adding in our wordsgames dataset the letters order (all of them) and we can either remove them or gray them.
(08:03:10 PM) djibb left the room (quit: Remote host closed the connection).
(08:26:11 PM) gandhi_m: bdoin, I always considered the native keyboard of the device the best option for keyboard, but see your point for preferring alphabetic order because of  teaching "reading not writing"
(08:27:00 PM) gandhi_m: I played around a bit with the native keyboard, another problem with it  might be, that it covers a big part of the display
(08:27:25 PM) gandhi_m: for gletters on tablets, it might not be practical for that reason
(08:28:58 PM) gandhi_m: your option for wordsgame would be easily to integrate, once we have a complete and correctly sorted list of keys for each locale
(08:29:33 PM) gandhi_m: maybe we can create it automatically, taking all letters, that are included in a json-file and sort it with QCollator on Linux ...
(08:29:57 PM) gandhi_m: mount
(08:50:03 PM) bdoin: if QCollator does the trick then yes implementing it is the best option
(08:51:12 PM) gandhi_m: I meant only for the initial generation of the sorted letters list that would then be stored in the wordsgame wordlist
(08:51:25 PM) gandhi_m: it does not seem to work on android
(08:51:49 PM) gandhi_m: so we probably need provide a presorte the letters-list
(08:52:04 PM) bdoin: ok, so preprocessing
hkaelberer moved this task from Backlog to WIP on the GCompris board.Feb 11 2016, 8:49 PM

On Android there is still no ICU backend for QCollator as of Qt 5.5.1.

I'd propose to use a wrapper around QCollator on Linux and implement it using JNI-wrapper around Collator/Locale on Android. This seems to work.

Can't test on other platforms, though.