Ade Malsasa Akbar contact
Senior author, Open Source enthusiast.
Sunday, August 26, 2018 at 22:05

Suppose you want to translate Dolphin File Manager into your language --say, Indonesian-- and quickly preview each change. You can do it as long as you know the basic workflow and commands. You will be able to translate the menubar, toolbar, configurations, and more to your language. Here's a simple guide that is very easy for anyone to try out and have fun. Enjoy!

Subscribe to UbuntuBuzz Telegram Channel to get article updates directly.


1. The Basics

  1. Translating is actually editing .po file of the program.
  2. The .po file is available in the L10N website of program. For example, all KDE programs are here
  3. Translated .po file should be transformed into binary .mo file.
  4. Testing and previewing translation is basically running the program from Terminal: for example, to run in Indonesian: $ LANGUAGE=id dolphin or to run in Japanese: $ LANGUAGE=ja dolphin
  5. You don't need to logout or even re-compile program's source code in order to apply and preview your translation.
As an example, this tutorial assumes you will translate into Indonesian ("id").

2. The Files and Directories Needed

  • In this example, you will need dolphin.po and also kxmlgui5.po files. You will download them.
  • The folder to put translations is /usr/share/locale/id/LC_MESSAGES/

3. The Connection Between PO and GUI

Between the code and the real interface, of course, there is a connection. You will find it by comparing kxmlgui5.po and your Dolphin menubar. Start from the string "&File" like below. Each string (word) you see on your Dolphin interface is stored either in PO file like kxmlgui5.po or other PO files.

See the Dolphin menubar (back) and the Find: (front)

4. The Commands Used

Install first the GNU gettext package that contains msgfmt command:
$ sudo apt-get install gettext

Basically, you will use only 3 commands repeatedly:
  • $ msgfmt dolphin.po
  • $ sudo mv -v /usr/share/locale/id/LC_MESSAGES/
  • $ LANGUAGE=id dolphin
First command transforms (compiles) source .po into binary .mo file. Second command copies .mo file to the correct place --otherwise the program could not read it. Third command calls the program to use your translation. Simple, right? 

5. How To Translate

  • # line is comment so ignore it
  • msgid line is source language
  • msgstr line is target language (you translate here)

Getting the PO files: 

Editing PO file

Translating Dolphin menubar: 
  • Open kxmlgui5.po with text editor. 
  • Find out "&File", "&Edit", "&View", "&Help"or such string.
  • Put the translation "&Berkas", "&Sunting", "&Tampilan", "B&antuan" respectively, in each msgstr field under the msgid field.
  • Use your Terminal to compile it: 
    • $ msgfmt kxmlgui5.po --output
  • Move it to program directory: 
    • $ sudo mv -v /usr/share/locale/id/LC_MESSAGES/
  • See below to test & preview it.

Translating Dolphin features & configurations:
  • Open dolphin.po with text editor.
  • Find out "New Tab", "Close Tab" or such strings from submenus, or "Startup", "View Mode" or such strings from configurations.
  • Again, put your translation in each msgstr field under the msgid field.
  • Use your Terminal to compile it:
    • $ msgfmt dolphin.po --output
  • Move it to program directory:
    • $ sudo mv -v /usr/share/locale/id/LC_MESSAGES/
  • See below to test & preview it.

6. Preview Translation

For any change you made:
$ LANGUAGE=id dolphin

That should open Dolphin File Manager with the language selected. This way you can test your own translation. Each program read translations from .mo files in /LC_MESSAGES/ directory. See this picture. It's done, right?

Preview it directly on the program

Applying to Other Programs

Is this tutorial only for KDE Dolphin? No, it is not, as you can apply the very same steps for GNOME programs, XFCE programs, and any other programs you find available with the .po. Again, I use Dolphin here only as an example.

Applying to Other Languages

Do you speak Arabic ("ar"), Japanese ("ja"), or Spanish ("es")? Easy. The steps above are for you except you change the target directory from /id/ into your language code. For example, for Arabic, put the .mo in /usr/share/locale/ar/LC_MESSAGES/ then call the program with the command  $ LANGUAGE=ar dolphin . Simple and easy, no?


This article is licensed under CC BY-SA 3.0.