Some translators want to know how they can apply their translated entries to Linux Deepin immediately after translation, without waiting for us to merge the translation, so that they can verify their translation on their current system. Below is a quick and dirty way of doing this.

We are going to use a tool called msgfmt, with which we can generate .mo files from .po files. Let's take the Romanian translation for Linux Deepin's desktop clock widget as an example. As there is only one string, which is "Change Appearance", needed translation. We can easily see the difference when we have applied the translation.

Before you continue, make sure that your system's locale environment is in Romanian (If it is not, you can edit the /etc/default/locale file to change your system's default locale. If it does not work, you probably have used the GNOME Language Selector before. The GNOME Language Selector changes the local variables for locales somewhere I cannot find. In this case you can try the tool again to change your system's default language.):

$ locale
LANG=ro_RO.UTF-8
LANGUAGE=ro:zh_CN:en
LC_CTYPE="ro_RO.UTF-8"
LC_NUMERIC=ro_RO.UTF-8
LC_TIME=ro_RO.UTF-8
LC_COLLATE="ro_RO.UTF-8"
LC_MONETARY=ro_RO.UTF-8
LC_MESSAGES="ro_RO.UTF-8"
LC_PAPER=ro_RO.UTF-8
LC_NAME=ro_RO.UTF-8
LC_ADDRESS=ro_RO.UTF-8
LC_TELEPHONE=ro_RO.UTF-8
LC_MEASUREMENT=ro_RO.UTF-8
LC_IDENTIFICATION=ro_RO.UTF-8
LC_ALL=

And we can see on our desktop many things are still in another language, including the clock widget on desktop. (In my case it falls back into Chinese, as much of the Romanian translation is still missing.)

before-applying-translation

1. Downloading the .po file we have been working on from Transifex.
(The awkward design of Transifex made me decide to give an explanation of the way to download it. If you do not think so or you know how to download it yourself, just skip to the next step.)
First, enter the project details page for Clock Desktop Plugin on Transifex.

enter-the-project-details-page-on-transifex

In the project details page, click on the Romanian option, and download the .po file for the language from the page you opened.

download-the-po-file-for-the-romanian-language

Now we have the .po file with the name for_use_clock-desktop-plugin_clockpot_ro.po

2. Generating the .mo file. We can use the msgfmt command to generate an .mo file:
A simple command will do.

$ msgfmt for_use_clock-desktop-plugin_clockpot_ro.po -o clock.mo

3. Replacing the .mo file
Now comes the interesting part. We need to replace the .mo file we are currently using on our system with the one we have just generated. Let's find out where the .mo file for the desktop plugin is located:

$ dpkg -L deepin-desktop-environment-plugins-clock | grep ro.*mo

/user/share/dde/resources/desktop/plugins/clock/locale/mo/ro/LC_MESSAGES/clock.mo

Back up the original .mo file and then replace it:

$ pushd /user/share/dde/resources/desktop/plugins/clock/locale/mo/ro/LC_MESSAGES
$ sudo cp clock.mo clock.mo.backup
$ sudo cp ~/clock.mo .
$ popd

Log out and log in again, we'll then see that the translation for Clock Desktop Plugin has been successfully applied.

after-applying-translation

2 Comments

Leave a Reply