<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://maemo.octonezd.me/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=82.245.13.39</id>
	<title>Maemo Wiki Mirror - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://maemo.octonezd.me/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=82.245.13.39"/>
	<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php/Special:Contributions/82.245.13.39"/>
	<updated>2026-04-22T05:55:51Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=Documentation/Maemo_5_Developer_Guide/Application_Development/Maemo_Localization&amp;diff=6431</id>
		<title>Documentation/Maemo 5 Developer Guide/Application Development/Maemo Localization</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=Documentation/Maemo_5_Developer_Guide/Application_Development/Maemo_Localization&amp;diff=6431"/>
		<updated>2010-02-15T14:02:18Z</updated>

		<summary type="html">&lt;p&gt;82.245.13.39: /* Testing */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Maemo Localization =&lt;br /&gt;
&lt;br /&gt;
== Overview ==&lt;br /&gt;
&lt;br /&gt;
This section describes how to localize maemo applications. Localization is needed to provide native translations of the software. The section contains information on how to localize an application, how to ease extraction of message strings, how to make the translations, and how to test the localization.&lt;br /&gt;
&lt;br /&gt;
Changes are presented with code examples to help the localization process. MaemoPad is used as an example here.&lt;br /&gt;
&lt;br /&gt;
== Localization ==&lt;br /&gt;
&lt;br /&gt;
Localization means translating the application to different languages. Maemo localization is based on the standard gettext package, and all the necessary tools are included in Scratchbox. For applications, localization requires a couple of files in the po/ directory. The following files will be used for localization:&lt;br /&gt;
&lt;br /&gt;
 Makefile.am&lt;br /&gt;
 en_GB.po&lt;br /&gt;
 fi_FI.po&lt;br /&gt;
 POTFILES.in&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;POTFILES.in&#039;&#039;  contains the list of source code files that will be localized. File &#039;&#039;en_GB.po&#039;&#039;  includes translated text for target en_GB and file &#039;&#039;fi_FI.po&#039;&#039;  for target fi_FI.&lt;br /&gt;
&lt;br /&gt;
== Localizing Application ==&lt;br /&gt;
&lt;br /&gt;
To localize an application, l10n needs to be set up before &amp;lt;code&amp;gt;gtk_init()&amp;lt;/code&amp;gt; by including the following headers:&lt;br /&gt;
&lt;br /&gt;
maemopad/src/main.c &lt;br /&gt;
&lt;br /&gt;
 #include &amp;lt;locale.h&amp;gt;&lt;br /&gt;
 #include &amp;lt;glib/gi18n.h&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To initialize the locale functions, the following lines need to be added:&lt;br /&gt;
&lt;br /&gt;
maemopad/src/main.c &lt;br /&gt;
&lt;br /&gt;
 setlocale(LC_ALL, &amp;quot;&amp;quot;);&lt;br /&gt;
 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);&lt;br /&gt;
 bind_textdomain_codeset(GETTEXT_PACKAGE, &amp;quot;UTF-8&amp;quot;);&lt;br /&gt;
 textdomain(GETTEXT_PACKAGE);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The most important of these are &#039;&#039;GETTEXT_PACKAGE&#039;&#039;  and &#039;&#039;localedir&#039;&#039; , which come from configure.ac:&lt;br /&gt;
&lt;br /&gt;
maemopad/configure.ac &lt;br /&gt;
&lt;br /&gt;
 AC_PROG_INTLTOOL([0.23])&lt;br /&gt;
 #PACKAGE=maemopad by default, defined by AM_INIT_AUTOMAKE&lt;br /&gt;
 GETTEXT_PACKAGE=$PACKAGE&lt;br /&gt;
 AC_SUBST(GETTEXT_PACKAGE)&lt;br /&gt;
 AC_DEFINE_UNQUOTED([GETTEXT_PACKAGE], &amp;quot;${GETTEXT_PACKAGE}&amp;quot;, [gettext pakname])&lt;br /&gt;
 ALL_LINGUAS=&amp;quot;en_GB fi_FI&amp;quot;&lt;br /&gt;
 AM_GLIB_GNU_GETTEXT&lt;br /&gt;
 # Application locale install directory, /usr/share/locale by default&lt;br /&gt;
 localedir=`$PKG_CONFIG osso-af-settings --variable=localedir`&lt;br /&gt;
&lt;br /&gt;
Of these, only GETTEXT_PACKAGE needs special attention, as it is the l10n domain that is to be used, and ALL_LINGUAS lists the available translations.&lt;br /&gt;
&lt;br /&gt;
=== Easing Extraction of Strings ===&lt;br /&gt;
&lt;br /&gt;
In the source code, there are multiple strings that eventually get shown in the user interface. For example:&lt;br /&gt;
&lt;br /&gt;
 maemopad_window_show_error (&amp;quot;maemopad_open_failed&amp;quot;, self);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In order to make the strings localizable, they need to be wrapped in &amp;lt;code&amp;gt;gettext(&amp;quot;String&amp;quot;)&amp;lt;/code&amp;gt; calls. In practice, writing &amp;lt;code&amp;gt;gettext()&amp;lt;/code&amp;gt; for every string is tedious. The common practice is to set the following #define which is already done in included &#039;&#039;gi18n.h&#039;&#039;:&lt;br /&gt;
&lt;br /&gt;
 #define _(String) gettext (String)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Thus, the i18n version of the example would be:&lt;br /&gt;
&lt;br /&gt;
maemopad/src/main.c&lt;br /&gt;
&lt;br /&gt;
 maemopad_window_show_error (_(&amp;quot;maemopad_open_failed&amp;quot;), self);&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Creating Translation Files ===&lt;br /&gt;
&lt;br /&gt;
Creating *.po files is quite straightforward. Maemopad has two localization files, &#039;&#039;en_GB.po&#039;&#039; and &#039;&#039;fi_FI.po&#039;&#039;. Creating the Finnish translation is explained next. Localization .po files are filled with simple structures, defining the localization id and the actual text string, e.g.&lt;br /&gt;
&lt;br /&gt;
 #: src/maemopad-window.c:573 src/maemopad-window.c:580&lt;br /&gt;
 msgid &amp;quot;maemopad_open_failed&amp;quot;&lt;br /&gt;
 msgstr &amp;quot;Open failed!&amp;quot;&lt;br /&gt;
&lt;br /&gt;
&amp;quot;msgid&amp;quot; defines the original string (key) used in code, and &amp;quot;msgstr&amp;quot; defines the translated string for localization.&lt;br /&gt;
&lt;br /&gt;
First, a template file is created with all strings from sources for translation. GNU xgettext command is used to extract the strings from sources:&lt;br /&gt;
 &lt;br /&gt;
 [sbox-FREMANTLE_X86: ~/maemopad] &amp;amp;gt; xgettext -f po/POTFILES.in -C -a -o po/template.po&lt;br /&gt;
&lt;br /&gt;
Option &amp;quot;-f po/POTFILES.in&amp;quot; uses POTFILES.in to get the files to be localized, &amp;quot;-C&amp;quot; is for C-code type of strings, &amp;quot;-a&amp;quot; is for ensuring that all the strings are received from sources, and &amp;quot;-o template.po&amp;quot; defines the output filename.&lt;br /&gt;
&lt;br /&gt;
This may output some warnings. Usually they are not serious, but it is better to check them anyway.&lt;br /&gt;
&lt;br /&gt;
If the translation in question is into Finnish, the edited &#039;&#039;po/template.po&#039;&#039;  needs to be copied to &#039;&#039;po/fi_FI.po&#039;&#039; , and &#039;&#039;fi_FI.po&#039;&#039;  needs to be added to ALL_LINGUAS in &#039;&#039;configure.ac&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Now &#039;&#039;po/fi_FI.po&#039;&#039;  will include lines such as the following:&lt;br /&gt;
&lt;br /&gt;
 #: src/maemopad-window.c:253&lt;br /&gt;
 msgid &amp;quot;maemopad_save_changes_made&amp;quot;&lt;br /&gt;
 msgstr &amp;quot;Save changes?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
All msgstrings should be translated into the desired language:&lt;br /&gt;
&lt;br /&gt;
 #: src/maemopad-window.c:253&lt;br /&gt;
 msgid &amp;quot;maemopad_save_changes_made&amp;quot;&lt;br /&gt;
 msgstr &amp;quot;Tallenna muutokset?&amp;quot;&lt;br /&gt;
&lt;br /&gt;
Autotools should now automatically convert the .po file to .mo file during the build process, and install it to the correct location.&lt;br /&gt;
&lt;br /&gt;
To do it manually:&lt;br /&gt;
 &lt;br /&gt;
 [sbox-FREMANTLE_X86: ~/maemopad] &amp;gt; msgfmt po/fi_FI.po -o debian/maemopad/usr/share/locale/fi_FI/LC_MESSAGES/maemopad.mo&lt;br /&gt;
&lt;br /&gt;
Where &amp;quot;debian/maemopad/usr/share/locale/fi_FI/LC_MESSAGES/&amp;quot; is the directory where the software should be installed to.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
Inside scratchbox, the translated application should be tested by setting LANGUAGE environment variable to contain the newly created locale (in this example case for Finnish translation, &amp;quot;fi_FI&amp;quot;):&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
 [sbox-FREMANTLE_X86: ~] &amp;gt; LANGUAGE=&amp;quot;fi_FI&amp;quot; run-standalone.sh maemopad&lt;br /&gt;
&lt;br /&gt;
On the target device, a wrapper script is needed to accomplish this, if the device does not have a locale for the locale identifier used. The script can simply consist of:&lt;br /&gt;
&lt;br /&gt;
 #!/bin/sh&lt;br /&gt;
 LANGUAGE=&amp;quot;fi_FI&amp;quot; /usr/bin/maemopad&lt;br /&gt;
&lt;br /&gt;
The example above assumes that the installation package installs the executable into /usr/bin. This script needs then to be configured to be run in the application&#039;s .desktop file, instead of the actual executable.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:Documentation]]&lt;br /&gt;
[[Category:Fremantle]]&lt;/div&gt;</summary>
		<author><name>82.245.13.39</name></author>
	</entry>
</feed>