How to Write With Any Language in Linux
When it comes to typing text in languages other than English, Mac users are used to going to a single System Preferences screen, enabling a language or two, then having all the necessary tools at their disposal. The process for Windows users is only slightly more convoluted.
Android users, on the other hand, can choose from a number of different language input tools, and the same applies to Linux. Once installed these input method editors, or IMEs, allow Linux users to input text in their native language.
There are a few key concepts to understand when working with multi-lingual text. The language you see on your screen, both when you are entering it and when the computer is displaying it for you, depends on the following parts.
- Text encoding is the most basic of these, and describes how bytes of data represent the characters you see on screen. Nowadays modern systems recognize the UTF standard, which is an encoding scheme that includes characters for most of the world’s languages.
- Locale is how those modern operating systems also handle the display of different languages in the UI. So if your locale is English you’ll see a phrase like “Shut Down” in the Power menu, while if you’re using the French locale you’ll see a translation of it. It also manages the display format for currency and date/time format (e.g. Americans are used to MM-DD-YYYY format, whereas many countries use DD-MM-YYYY). Most users will set their “language” (which is really the system’s locale) when they install their OS, or start up a new machine for the first time, and not mess with it thereafter.
- Input is how you go about entering text into your PC. There are different ways to do this. The keyboard is probably what you think of first, but it’s not the only way. There’s handwriting, voice-to-text, and even optical character recognition (OCR) , each of which has its own foreign language considerations. It’s keyboard input we’ll examine in the below sections.
We can cover text entry in a majority of foreign languages as follows:
- Languages that can be entered with a change to keyboard settings. If you’re a speaker of European languages, switching keyboard configurations should be enough for you.
- Languages that are entered with the help of an Input Method Editor (IME). Languages that use non-Latin character sets (e.g. Chinese, Hindi, and Arabic) often use an IME with keyboard text entry.
Entering Foreign Language Text via Keyboard Settings
Western languages consist of mostly Latin characters plus various accent marks. So an English keyboard is sufficient to tell the OS what “base character” you want to type. The trick is how to indicate the accents. Linux desktops provide two different ways to do this, though they operate in basically the same way, similar to the way it’s done on Chromebooks .
The first method uses your current keyboard layout. But you can designate one of its keys as the Compose key. A common choice is the right Alt key, sometimes labeled Alt Gr. When you hold this key down and enter other characters in the correct order, the system takes them to mean the accented character. For example, when holding the Compose key and pressing e then ‘ (a single quote), this is interpreted as “e with an acute accent”: é. This method is useful if you’re using these characters relatively often, as you’ll always have access to them. A downside is that you’ll lose use of your right Alt key for functions such as switching tasks (the left Alt will still work in this regard).
The setting for this can be found in the KDE System Settings > Input Devices > Keyboard screen, then click the Advanced tab, and look for the option called Position of Compose Key. It lists several options, just select your favorite and click Apply. To do the same thing in Unity, go to Sytem Settings > Keyboard, then click on the Shortcuts tab. Select the Typing item, and you’ll be able to configure the Compose Key on the right.
Alternately, you can set up a new keyboard layout that includes the keys necessary to produce accented characters. In KDE, this is available in System Settings > Input Devices > Keyboard, then click on the Layouts tab. Check the Configure Layouts box and you should see a listing in the Layout column for your default keyboard, the one you selected at install time, e.g. “English (US)” as shown below (unless you’ve delved into the world of alternative layouts ). Click the Add button, then select the first two settings to match your hardware (English for the language and English (US) for me here). The Variant is the important one here — select English (US, international with dead keys).
In Unity, right-click on the keyboard icon (En for English speakers) in the top-right of the menu bar, and select the Text Entry item. In the Text Entry window, click the + to add a Text Entry method, then search for English (International AltGR dead keys).
Now when you press and hold one of the “dead keys” (one is typically the aforementioned “Alt Gr”) and press a compatible key afterward, it will enter an accented letter instead. For example, typing “Alt Gr + Y” produces the version with umlaut: ü. This method is more suited to users who do more than the occasional character, as you can switch into “foreign language mode” and stay there, then switch back to “English mode” when you’re done. It’s also slightly less intuitive to some, and will require setting aside some mental RAM to memorize the combinations (as opposed to Alt Gr + E + single quote, which you could probably guess yourself).
The key combinations for these methods can be slightly different, so it’s advisable to select one and stick with it.
Entering Foreign Language Text via Input Method Editor
As many computers come with an English keyboard, creating text may seem elementary to English speakers and their 26-letter alphabet. But consider languages like Japanese, which has over 10,000 characters. How can you enter these using a keyboard that has only 101 (or 105, but certainly not 10,000) keys?
This is where an input method editor, or IME, comes in. It’s the piece of software that’s responsible for taking user input and turning it into the desired character. The most common way to do this on PC’s is converting keystrokes. But applets that take handwriting or virtual keyboards are also types of IMEs.
The install steps are highly dependent on: 1) your selection of IME framework/manager, 2) whether or not it’s modular, 3) installation of the module(s) for your language(s), and 4) how you access that IME from the desktop.
Below describes the steps to install the Japanese language on KDE and Unity for the fcitx input method framework to use the mozc Japanese IME extension. Essentially, we’re setting up fcitx so we have a unified experience if we want to add other languages in the future.
Installation and Configuration in GTK-Based Desktops
In desktops that use GTK, such as Unity, search in the Dash for the Language Support configuration tool. This lists the different languages you can add to the system. Once you select the one you want, the tool will start installing all the various packages you might need, including fonts and app translations. Once it’s installed re-log in so the new language(s) will be available.
To start using them, right-click the keyboard icon in the top-right corner of your screen, and select the Text Entry option. Now, when you add a Text Entry method, you’ll see options for the language you just added. Ubuntu uses the mozc input method with the ibus framework, but you can switch to fcitx manually. Speaking of which…
Installation and Configuration in KDE
To use Japanese in KDE Neon, let’s install the fcitx framework, the KDE System Settings module, and the mozc Japanese input method. You can substitute mozc for an input method that supports your language. The Settings module won’t install these for us like Unity, so let’s take care of it.
sudo apt-get install kde-config-fcitx fcitx-mozc
Once this is complete, you should see the fcitx configurations in System Settings > Regional Settings > Input Method.
Next, add the Input Method Panel widget to your taskbar somewhere.
Now start fcitx by selecting it from the Applications > Utilities menu, or with the following at the command line:
Now you should be ready for your writing to start turning Japanese, right? Wrong. There’s one more very important but not well documented step for KDE applications to accept input from the IME. Issue the following at the command line:
im-config -n fcitx
This configures fcitx to be your “active configuration” (the Unity screen provides a drop-down to select this). If you don’t, it will fall back to normal (boring, English) input from the keyboard. It’s also advisable to log out of your session and log back in again (you don’t need to reboot, however).
Now you can open a KDE app, hit the hotkey you configured (Ctrl + Space by default), and go on a little language vacation (notice the Japanese-y fcitx icons in the system tray).
It’s as simple as that: you should now be writing in Japanese (or whichever language you wanted to switch to)!
Do you use Linux in multiple languages? Have a preference between the Compose Key versus using a keyboard layout? Recommend a particular IME? Let us know in the comments!