Active Topics

 


Reply
Thread Tools
Posts: 85 | Thanked: 383 times | Joined on Jan 2010 @ Hong Kong
#1
Hi everyone,

I'm currently in the process of creating an application targeted for the Chinese communities. While it is possible to create localized UIs via *.po/*.mo as well as control file for packaging, I cannot find a way to display the localized name of the application in the application icon based on current system language.

I've read through the wiki page and it doesn't mention anything about localization. It does provide a freedesktop.org link for further reading and the freedesktop.org spec does mention something related. I then tried to modify the .desktop file of my app to the format similar to the following:

Name=MyApp Name in English
Name[zh_HK]=我的軟件 (MyApp Name in Chinese)

and reboot the device; but the application name in MyApp's icon is still the English one (my system's current language is zh_HK).

I've checked for the .desktop files of the system's bundled programs (e.g. Image Viewer) and found that the values in their "Name" field are in fact some "keys" (e.g. "imag_ap_images") that are referred by some *.mo files in /usr/share/locale/{lang}/LC_MESSAGES/ . So I wonder:
  • Is .desktop file localization achievable in Maemo 5? Viia the freedesktop.org way or the *.po/*.mo way?
  • Is there any official and complete specification document around this particular area?

I'm just a novice developer in the Maemo world and I'm looking forward to learning from you guys.
 

The Following User Says Thank You to amandalam For This Useful Post:
Posts: 85 | Thanked: 383 times | Joined on Jan 2010 @ Hong Kong
#2
With some testing, I think I know the answer now...localized application name shown in application icon is defined by using *.mo file.

For example, we define a /usr/share/applications/hildon/MyApp.desktop file with the following contents:

Code:
[Desktop Entry]
Encoding=UTF-8
Version=0.1
Name=MyAppName
Comment=My App
Exec=python /opt/MyApp/MyApp.py
Icon=MyApp
Type=Application
X-HildonDesk-ShowInToolbar=true
X-Text-Domain=MyApp
Then we will need to prepare localized .po files (take zh_HK.po as example) with the following contents:

Code:
msgid ""
msgstr ""
"Project-Id-Version: MyApp\n"
"Report-Msgid-Bugs-To: my-email@my-email.com\n"
"POT-Creation-Date: 2010.05.16 14:11+0300\n"
"PO-Revision-Date: 2010-06-21 12:26+0800\n"
"Last-Translator: My Name <my-email@my-email.com>n"
"Language-Team: en_US\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"Plural-Forms: nplurals=2; plural=n != 1\n"

msgid "MyAppName"
msgstr "好程式"

Use the msgfmt tool to generate the .mo file and place the .mo file to the corresponding locale directory:

Code:
msgfmt zh_HK.po -o /usr/share/locale/zh_HK/LC_MESSAGES/MyApp.mo
Please note that the "MyApp" in the .mo filename must be the same as the value specified in the X-Text-Domain section of the .desktop file.

Don't forget to prepare two PNG images, one with 48x48 and one with 64x64 resolution, and place them to:

Code:
/usr/share/icons/hicolor/48x48/apps/MyApp,png  (48x48)

/usr/share/icons/hicolor/scalable/hildon/MyApp.png  (64x64)
And that's it. You will see "好程式" as the application name when you switch to the zh_HK locale

Last edited by amandalam; 2010-06-23 at 01:20.
 

The Following 3 Users Say Thank You to amandalam For This Useful Post:
Reply


 
Forum Jump


All times are GMT. The time now is 08:54.