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.):
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.)
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.
In the project details page, click on the Romanian option, and download the .po file for the language from the page you opened.
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
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 .
Log out and log in again, we'll then see that the translation for Clock Desktop Plugin has been successfully applied.