Toggle Your Keyboard Between Languages

by Darrel Johnston (djohnston)

PCLinuxOS is primarily an English language distribution. There are French, Polish and Brazilian forums that I know of. But, PCLinuxOS users come from all over the world. Many prefer to use the system in their native language. And, some want to be able to switch between their native language and English or some other language. Occasionally, a new user posts on the main forum, wanting to know how to switch keyboard languages without logging out or reconfiguring the preferred language and keyboard. The answer is the subject of this article.

Although many Linux distributions offer this feature “out of the box”, PCLinuxOS does not. It is, however, a relatively easy task to add this capability. First, one must set up the keyboard for their native language. In this example, I am using US English as the main language. Your choice may be different. Open the PCLinuxOS Control Center and click System in the left pane and Localization in the right pane. I chose American English as my language.

And I chose United States as my country.

After saving your settings, click Hardware in the left pane of PCLinuxOS Control Center and Setup the keyboard layout in the right pane. I chose US International keyboard for the keyboard layout and and 105-key (Intl) PC for the keyboard type.

Close the PCLinuxOS Control Center and open Synaptic. As a rule of thumb, always completely update your system before adding any new packages. Do a search in Synaptic for “locales” (without the quotation marks). There will be a main locales package already installed. There are many language localization packages listed. Choose the languages you wish to use and install the corresponding locales packages. I chose Arabic and Russian. After the locales packages are installed, close Synaptic.

For the last step, open the text editor of your choice. Paste the following text into the editor’s window.

[Desktop Entry]

Name=Keyboard-toggle

Comment=Toggle between keyboard layouts with Alt-Shift

Encoding=UTF-8

Exec=setxkbmap -option grp:switch,grp:alt_shift_toggle,grp_led:scroll us,ar,ru

Icon=/usr/share/icons/gnome/48x48/devices/keyboard.png

Terminal=false

Type=Application

Categories=GTK;System;Monitor;X-MandrivaLinux-System-Monitoring

StartupNotify=false

Save the file as ~/.local/share/applications/Keyboard-toggle.desktop. (The ~ symbol represents your home directory, and the system will treat it as such.) Notice the “us,ar,ru” portion at the end of the “Exec=” line. Change those entries to whatever languages you are using. You can use more than two languages. Saving the file in your home directory will ensure that no system updates will overwrite the desktop file. Once it is saved, you will have a new entry in the More Applications > Monitoring section of the main menu, named Keyboard-toggle. To enable the keyboard switcher, run Keyboard-toggle from the menu. The Alt-Shift key combination will switch between your choice of languages. Shown below are US English, Russian and Arabic entered in a text editor. The Arabic portion is on the right side of the window because Arabic is one of the languages that is written from right to left.

To automatically start the keyboard switcher every time you log in, add it to your desktop as a startup program.