Detecting current Keyboard layout in English

Pantelis Koukousoulas pktoss at gmail.com
Sat Apr 13 11:01:42 PDT 2013


Hey everyone,

As you know, in Windows libreoffice detects the current input language
and can change the current document language accordingly (assuming
the user wants this). This works great for language pairs like english/greek
that use different alphabets / layouts.

It would be nice to have this functionality in Linux as well. I don't believe
it will solve all spellchecking issues (e.g., it will still be
desirable to be able
to do trigram-based language detection per word as well), but it would be
a step in the right direction.

So, I think this comes down to having a way to be notified about a change
in the keyboard layout and to get the current layout for each backend
so that GetInputLanguage() in the SalFrame backends of Linux will
return something better than  LANGUAGE_DONTKNOW. It seems to
me that nowadays we could do this using dbus.

For KDE:
in vcl/unx/kde4/KDESalFrame.cxx:
  -> It should listen for "currentLayoutChanged()" signal and use
      getCurrentLayout() of org.kde.keyboard / org.kde.keyboardLayouts

For GNOME:
in vcl/unx/gtk/window/gtkframe.cxx:
   -> The list of available layouts can be found in
        org.gnome.desktop.input-sources sources.
   -> The index of the current layout can be read in
        org.gnome.desktop.input-sources current.
   -> So, it should be possible to subscribe to the changed
       event for this key.

Does this sound like a reasonable plan, is there something
I have misunderstood in how input language detection works
in libreoffice?

Thanks in advance for any suggestions

Regards,
Pantelis


More information about the LibreOffice mailing list