<?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=173.212.211.28</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=173.212.211.28"/>
	<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php/Special:Contributions/173.212.211.28"/>
	<updated>2026-04-22T10:42:48Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=MicroB_tweaks&amp;diff=25833</id>
		<title>MicroB tweaks</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=MicroB_tweaks&amp;diff=25833"/>
		<updated>2010-11-29T13:02:06Z</updated>

		<summary type="html">&lt;p&gt;173.212.211.28: /* Also see */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;(Maemo 4 only. Maemo 5 status not clear at this time of writing.)&lt;br /&gt;
&lt;br /&gt;
MicroB is the default browser in Maemo 4. While there are alternative browsers for Maemo 4 such as [[Tear]] and [[Firefox mobile]] some users prefer MicroB.&lt;br /&gt;
&lt;br /&gt;
It is possible to tweak the performance and behaviour of MicroB. Please continue to read for some suggestions.&lt;br /&gt;
&lt;br /&gt;
MicroB, being a [[:wikipedia:Mozilla|Mozilla]] based browser, has the same settings as Firefox. These settings are stored in the file &amp;lt;code&amp;gt;/home/user/.mozilla/microb/prefs.js&amp;lt;/code&amp;gt;. Only a few of these settings can be changed from the MicroB menus. To change the others open the url about:config in MicroB to edit them one-by-one, or edit prefs.js.&lt;br /&gt;
&lt;br /&gt;
== Settings ==&lt;br /&gt;
&lt;br /&gt;
Even though many of the settings only make sense on a notebook or desktop pc, there are some that can be useful for the Internet Tablets.&lt;br /&gt;
&lt;br /&gt;
Removes cookies when closing MicroB (allow only for session). This only applies to new cookies. To also delete earlier cookies go to Tools -&amp;gt; clear -&amp;gt;cookies in MicroB:&lt;br /&gt;
&lt;br /&gt;
 network.cookie.lifetimePolicy 2&lt;br /&gt;
&lt;br /&gt;
Activates smooth scrolling. This is useful when the [http://www.internettablettalk.com/wiki/index.php?title=Internet:Microb_Hardware_Key_bindings d-pad is configured for scrolling]:&lt;br /&gt;
&lt;br /&gt;
 general.smoothScroll true&lt;br /&gt;
&lt;br /&gt;
Lets you select the contents of the urlbar with one click, instead of the default triple click:&lt;br /&gt;
&lt;br /&gt;
 browser.urlbar.clickSelectsAll true&lt;br /&gt;
&lt;br /&gt;
Sets minimum and default font size in points, in this case 20 points. Depending on the language you use also set font.min-size.fixed.ja (japanese) etc.:&lt;br /&gt;
&lt;br /&gt;
 font.min-size.fixed.x-western 20&lt;br /&gt;
 font.min-size.fixed.x-unicode 20&lt;br /&gt;
 font.min-size.variable.x-western 20&lt;br /&gt;
 font.min-size.variable.x-unicode 20&lt;br /&gt;
 font.size.variable.x-western 20&lt;br /&gt;
 font.size.fixed.x-unicode 20&lt;br /&gt;
&lt;br /&gt;
Speed tweaks specific for the Internet Tablets:&lt;br /&gt;
&lt;br /&gt;
 browser.cache.memory.capacity 8192&lt;br /&gt;
 browser.sessionhistory.max_entries 4&lt;br /&gt;
 content.notify.interval 1250000&lt;br /&gt;
 content.notify.ontimer true&lt;br /&gt;
 network.http.max-connections 4&lt;br /&gt;
 network.http.max-connections-per-server 4&lt;br /&gt;
 network.http.max-persistent-connections-per-server 1&lt;br /&gt;
 network.http.pipelining.maxrequests 1000&lt;br /&gt;
 network.http.pipelining true&lt;br /&gt;
 nglayout.initialpaint.delay 2000&lt;br /&gt;
&lt;br /&gt;
For an explanation of these and other settings in about:config see [http://www.tweakguides.com/Firefox_10.html this article.]&lt;br /&gt;
&lt;br /&gt;
== Editing  prefs.js ==&lt;br /&gt;
&lt;br /&gt;
To edit it on the tablet itself:&lt;br /&gt;
 &lt;br /&gt;
* if you don&#039;t have root access already install &#039;rootsh&#039; through the application manager&lt;br /&gt;
* if you don&#039;t have &#039;nano&#039; installed get it with application manager&lt;br /&gt;
* close all MicroB windows&lt;br /&gt;
* open xterm&lt;br /&gt;
 sudo gainroot&lt;br /&gt;
 invoke-rc.d tablet-browser-daemon stop &lt;br /&gt;
 exit&lt;br /&gt;
 cd .mozilla/microb&lt;br /&gt;
 cp prefs.js prefs.js.backup&lt;br /&gt;
 nano prefs.js&lt;br /&gt;
&lt;br /&gt;
* scroll to the line you want to change/add and type the changes. Be careful to use the exact format user_pref(&amp;quot;nameofthesetting&amp;quot;, thevalue); . If you leave out one &#039;;&#039; , &#039;(&#039; etc. then the settings in the file will be ignored by MicroB.  If a setting does not exist then add it yourself.&lt;br /&gt;
* to save the file click ctrl, x, y, return.&lt;br /&gt;
 sudo gainroot&lt;br /&gt;
 invoke-rc.d tablet-browser-daemon start&lt;br /&gt;
 exit&lt;br /&gt;
 &lt;br /&gt;
If you decide to edit prefs.js on your own computer be sure to:&lt;br /&gt;
&lt;br /&gt;
* run as root &amp;quot;invoke-rc.d tablet-browser-daemon stop&amp;quot; before editing and &amp;quot;invoke-rc.d tablet-browser-daemon start&amp;quot; after editing.&lt;br /&gt;
* use an editor that uses linux style line endings&lt;br /&gt;
* restore the right permissions and ownership of the file when you put it back&lt;br /&gt;
&lt;br /&gt;
== Settings that will not stick ==&lt;br /&gt;
&lt;br /&gt;
Some settings get reset when MicroB starts. This is unfortunate, but you&#039;ll have to live with it.&lt;br /&gt;
&lt;br /&gt;
[[http://mxr.maemo.org/garage/source/browser/mozilla/trunk/microb-eal/include/common.h#70 list of interesting strings]]&lt;br /&gt;
&lt;br /&gt;
Replaced:&lt;br /&gt;
 * snav.keyCode.modifier&lt;br /&gt;
 * general.useragent.locale&lt;br /&gt;
 * general.useragent.vendor&lt;br /&gt;
&lt;br /&gt;
Randomly replaced with the value from plugins.flashhack:&lt;br /&gt;
 * ftv.enabled&lt;br /&gt;
 * snav.ignoreTextFields&lt;br /&gt;
 * snav.disableJS&lt;br /&gt;
 * layout.full.zoom.mode.fast&lt;br /&gt;
 * plugin.default_plugin_disable&lt;br /&gt;
 * security.warn_entering_secure&lt;br /&gt;
 * security.warn_leaving_secure&lt;br /&gt;
 * security.warn_submit_insecure&lt;br /&gt;
&lt;br /&gt;
For any such setting, you can use bookmarks to&lt;br /&gt;
 about:config?prefname={name}&amp;amp;prefvalue={value}&amp;amp;sprefname=donotomit&lt;br /&gt;
&lt;br /&gt;
... and just tap on them or if you only have one you can make it your home page.&lt;br /&gt;
&lt;br /&gt;
== How to restore the default settings==&lt;br /&gt;
&lt;br /&gt;
If you mess up prefs.js or just want the defaults back then either restore the backup file you just made, or delete prefs.js file so MicroB will regenerate it with default settings.&lt;br /&gt;
&lt;br /&gt;
to restore the backup: &lt;br /&gt;
&lt;br /&gt;
* close all MicroB windows&lt;br /&gt;
 sudo gainroot&lt;br /&gt;
 invoke-rc.d tablet-browser-daemon stop &lt;br /&gt;
 exit&lt;br /&gt;
 cd .mozilla/microb&lt;br /&gt;
 cp prefs.js.backup prefs.js&lt;br /&gt;
 sudo gainroot&lt;br /&gt;
 invoke-rc.d tablet-browser-daemon start&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
...or to delete prefs.js:&lt;br /&gt;
&lt;br /&gt;
* close all MicroB windows&lt;br /&gt;
 sudo gainroot&lt;br /&gt;
 invoke-rc.d tablet-browser-daemon stop &lt;br /&gt;
 rm /mozilla/microb/prefs.js&lt;br /&gt;
 invoke-rc.d tablet-browser-daemon start&lt;br /&gt;
 exit&lt;br /&gt;
&lt;br /&gt;
== Also see ==&lt;br /&gt;
&lt;br /&gt;
* [[Ad_blocking]]&lt;br /&gt;
* [http://www.internettablettalk.com/forums/showthread.php?t=24405 Selectively disable JavaScript in MicroB]&lt;br /&gt;
* [http://browser-extras.garage.maemo.org Browser-Extras, for MicroB extensions]&lt;br /&gt;
* [http://www.vistatweaks.net/ Windows tweaks] &lt;br /&gt;
&lt;br /&gt;
[[Category:Users]]&lt;br /&gt;
[[Category:Web]]&lt;br /&gt;
[[Category:Power users]]&lt;/div&gt;</summary>
		<author><name>173.212.211.28</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=MADDE/QtCreator_integration_for_Mac&amp;diff=14827</id>
		<title>MADDE/QtCreator integration for Mac</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=MADDE/QtCreator_integration_for_Mac&amp;diff=14827"/>
		<updated>2010-09-15T12:21:48Z</updated>

		<summary type="html">&lt;p&gt;173.212.211.28: /* Mac configuration */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{MADDE}}&lt;br /&gt;
&lt;br /&gt;
= QtCreator and MADDE on Mac OS X =&lt;br /&gt;
&lt;br /&gt;
This is a guide on how to enable MADDE in QtCreator. This is part of the technology preview. After following this guidance you are able to build your sources within QtCreator for your device, and deploy, run and debug your applications with few mouse clicks from your OS X installation.&lt;br /&gt;
&lt;br /&gt;
Requires:&lt;br /&gt;
&lt;br /&gt;
* [[MADDE]] installed on your Mac&lt;br /&gt;
* If you want to compile your code natively then you have to have [http://developer.apple.com/tools/xcode/ XCode] installed on your machine&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Install latest QtCreator on your Mac ==&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;You cannot use the latest official QtCreator for this. The version has to be &amp;gt;= 1.3.80! For these instructions the version of the 2010-03-04 is used!&#039;&#039;&#039; Find the latest build of QtCreator for Mac OS X here:&lt;br /&gt;
&lt;br /&gt;
http://qt.nokia.com/developer/qt-snapshots&lt;br /&gt;
&lt;br /&gt;
or here&lt;br /&gt;
&lt;br /&gt;
[http://www.mac-how.net/ mac how to]&lt;br /&gt;
&lt;br /&gt;
== Add Qt for Maemo5 ==&lt;br /&gt;
&lt;br /&gt;
You can change the configuration of the Qt-version in your QtCreator installation by clicking:&lt;br /&gt;
&lt;br /&gt;
 QtCreator -&amp;gt; Preferences -&amp;gt; Qt4 -&amp;gt; Qt Versions&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tip:&#039;&#039;&#039; If you do not see any Qt version by default here, you most likely haven&#039;t installed the needed Qt libraries to compile your Qt application for your Mac.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
In the next step you have to add the Qt version for Maemo5 to the configuration of QtCreator. It is needed to compile your sources for your Maemo device. Click on the &amp;quot;+&amp;quot; in the upper-right corner. The configuration form will ask you to enter a &amp;quot;Version name&amp;quot; and to locate &amp;quot;qmake&amp;quot;. You can find it in your MADDE installation folder under:&lt;br /&gt;
&lt;br /&gt;
 &amp;lt;MADDE_folder&amp;gt;/targets/&amp;lt;target_name&amp;gt;/bin&lt;br /&gt;
&lt;br /&gt;
For the &#039;&#039;&#039;standard installation&#039;&#039;&#039; it would be for example:&lt;br /&gt;
&lt;br /&gt;
 Version name: Maemo Qt4.5&lt;br /&gt;
 qmake Location: /Users/&amp;lt;username&amp;gt;/.madde/0.6.14/targets/fremantle-qt-0951/bin/qmake&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tip:&#039;&#039;&#039; You cannot find the folder if you click on &amp;quot;Choose...&amp;quot;, as it is hidden. But after entering &amp;quot;/Users/&amp;lt;username&amp;gt;/.madde/&amp;quot; in the text-field &amp;quot;qmake Location&amp;quot; you can select the rest via the &amp;quot;Choose...&amp;quot; button.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you will see Qt for Maemo as a new Qt Version in Qt Creator. But first you will see the red cross next to the Qt Version in the column &amp;quot;Debugging Helper&amp;quot;. The last step you have to do now is clicking on &amp;quot;Rebuild&amp;quot; and after a while (you can follow the status in the QtCreator main window) it should look like this:&lt;br /&gt;
&lt;br /&gt;
[[Image:01_mac_qtcreator_madde.png|500px]]&lt;br /&gt;
&lt;br /&gt;
== Configure device run-time in Qt Creator ==&lt;br /&gt;
&lt;br /&gt;
After setting up the connection between your Mac and your device, you will be able to compile, deploy, test and debug your application with a single mouse-click. The description shows the configuration for USB-networking and WLAN and is for each divided into two parts. It shows:&lt;br /&gt;
&lt;br /&gt;
* what to install on device, and&lt;br /&gt;
* how to set-up your Mac&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== General device set-up ===&lt;br /&gt;
&lt;br /&gt;
Please find the instructions on how to set up the device runtime from here:&lt;br /&gt;
&lt;br /&gt;
* [[MADDE/QtCreator_integration_for_windows#Install_the_client | Install the client]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== Connect via USB-networking ===&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Device configuration ====&lt;br /&gt;
&lt;br /&gt;
The following guide shows you, what to do on your device to set up the USB connection. This has to be done &#039;&#039;&#039;before&#039;&#039;&#039; you connect your device with the Mac:&lt;br /&gt;
&lt;br /&gt;
* [[MADDE/QtCreator_integration_for_windows#Configure_the_client_for_USB | Configure the client for USB networking]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==== Mac configuration ====&lt;br /&gt;
&lt;br /&gt;
Connect the device with your mac, open the network configurations out of the upcoming dialog and enter the following details. Finally click on &amp;quot;Apply&amp;quot;. Then the connection should be established.&lt;br /&gt;
&lt;br /&gt;
[[Image:02_mac_usbnetwork.png|400px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Possible connection problem:&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
In some versions of Mac OS X &#039;&#039;&#039; &amp;lt; 10.5.8&#039;&#039;&#039;, the system selects the [http://docwiki.gumstix.org/index.php/Setting_up_USBnet#USBnet_on_Mac_OS_X_10.5.X wrong interface] by default, so that you won&#039;t be able to connect your device as a network component with the Mac via USB. OS X detects the N900 in those cases as a modem and not as a network device. Follow these instructions to install the necessary driver information:&lt;br /&gt;
&lt;br /&gt;
http://bugcommunity.com/wiki/index.php/Start_Guide_Mac_OS_X_10.5&lt;br /&gt;
&lt;br /&gt;
[http://www.mac-how.net/article/Configuring_your_Mac_Mail_Client/ Configuring your Mac Mail Client]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
After installing the patch, you can connect the device and configure the network interface as shown in the screen-shot above.&lt;br /&gt;
&lt;br /&gt;
=== Connect via WLAN ===&lt;br /&gt;
&lt;br /&gt;
If both devices are connected to the same wireless network the configuration is a bit easier, but be aware that the IP address might not be the same all the time. This effects the set up of your QtCreator configuration.&lt;br /&gt;
&lt;br /&gt;
==== Device configuration ====&lt;br /&gt;
&lt;br /&gt;
Please open the mad-developer application. If you are connected already to the wireless network, you can find the IP address in the initial window of the application:&lt;br /&gt;
&lt;br /&gt;
[[Image:10_mac_mad-dev_wlan.png|300px]]&lt;br /&gt;
&lt;br /&gt;
==== Mac configuration ====&lt;br /&gt;
&lt;br /&gt;
Please just make sure, that your Mac and device are connected to the same network.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=== QtCreator Configuration ===&lt;br /&gt;
&lt;br /&gt;
After the connection between your PC and the device is set up, you can configure QtCreator to deploy and run the built applications on device. You can add your device in the configuration. You will find it in:&lt;br /&gt;
&lt;br /&gt;
 QtCreator -&amp;gt; Preferences -&amp;gt; Projects -&amp;gt; Maemo Device Configurations&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
First get the password from the Mad Developer application. You get it by clicking on &amp;quot;Developer Password&amp;quot; in the main view. &#039;&#039;&#039;Be aware&#039;&#039;&#039; that each time you click on the button, a new password will be created and that the password is only valid for the time it is shown in the application. &lt;br /&gt;
&lt;br /&gt;
[[Image:04_b_client_ready.png|300px]] [[Image:05_client_pw.png|300px]] &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Instructions for USB-network====&lt;br /&gt;
&lt;br /&gt;
Add the password and all the data you see in the screenshot below. Check the box, that you want to use the password as the authentication method. After that click on &amp;quot;test&amp;quot; and see if the connection can be set up.&lt;br /&gt;
&lt;br /&gt;
[[Image:03_mac_qtcreator_usbnetwork.png|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
====Instructions for WLAN====&lt;br /&gt;
&lt;br /&gt;
If your device is using the WLAN interface, please enter the IP address you can see in the mad-developer application on device.&lt;br /&gt;
&lt;br /&gt;
[[Image:04_mac_qtcreator_wlan.png|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tip&#039;&#039;&#039; You can use your ssh key for the connection. Click on &amp;quot;Deploy Key ...&amp;quot; and select your key. If the other settings are correct the key will be automatically deployed on your device, so that you don&#039;t have to worry about the passwords anymore.&lt;br /&gt;
&lt;br /&gt;
== Use Maemo5 build settings ==&lt;br /&gt;
&lt;br /&gt;
Now all the configuration is done and you can select Maemo as a build configuration. If you have a project, which you want to compile for Maemo, then click on the project button in the menu of the left side. Now you should seen a screen, like in the screen shot below. If you have the Qt libraries installed, then you will have the &amp;quot;Desktop&amp;quot; as the default option selected.&lt;br /&gt;
&lt;br /&gt;
[[Image:06_mac_qtcreator_init.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;Tip:&#039;&#039;&#039; &lt;br /&gt;
&lt;br /&gt;
* It might be that you don&#039;t see the &amp;quot;Desktop&amp;quot; widget in your project configuration. In this case it might be that the configuration of the MADDE is not correct, or that a little bug prevents the widget from showing up. In this case click on &amp;quot;Dependencies&amp;quot; and then go back to &amp;quot;Build&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
* If you start a new project you can add the Maemo build-configuration at the beginning:&lt;br /&gt;
&lt;br /&gt;
:[[Image:05_mac_qtcreator_select_madde.png|300px]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now press the plus in the widget, which shows, that &amp;quot;Desktop&amp;quot; is selected as default. This should open a new dialog, where you select &amp;quot;Maemo Device&amp;quot;. After that you will find a new build-configuration:&lt;br /&gt;
&lt;br /&gt;
[[Image:07_mac_qtcreator_maemo_build.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now click there on &amp;quot;Run&amp;quot; and select your device, which you have configured before. In the example it was called Maemo5 Device.&lt;br /&gt;
&lt;br /&gt;
[[Image:08_mac_qtcreator_maemo_run.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Finally you can now set in the down left corner, which build configuration you want to use:&lt;br /&gt;
&lt;br /&gt;
[[Image:09_mac_qtcreator_final.png]]&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Now you can click on the run button, and your application will be automatically compiled for the Maemo device, delpoyed, and started.&lt;br /&gt;
&lt;br /&gt;
[[Category:Development]]&lt;/div&gt;</summary>
		<author><name>173.212.211.28</name></author>
	</entry>
	<entry>
		<id>https://maemo.octonezd.me/index.php?title=Internationalize_a_Python_application&amp;diff=13439</id>
		<title>Internationalize a Python application</title>
		<link rel="alternate" type="text/html" href="https://maemo.octonezd.me/index.php?title=Internationalize_a_Python_application&amp;diff=13439"/>
		<updated>2010-07-15T12:14:50Z</updated>

		<summary type="html">&lt;p&gt;173.212.211.28: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;This page explains step by step how to add support for translations in a Python application for Maemo. &lt;br /&gt;
&lt;br /&gt;
There are already some [http://www.learningpython.com/2006/12/03/translating-your-pythonpygtk-application/ tutorials online] about how to internationalize (i18n) python applications, but i find them difficult to follow and they lack some needed code and final tricks to make everything work fine. &lt;br /&gt;
&lt;br /&gt;
To support i18n we need to accomplish 5 tasks:&lt;br /&gt;
# Define correctly a function &#039;_()&#039; that translates strings&lt;br /&gt;
# Mark the strings in the code with that function&lt;br /&gt;
# Generate a template for the translators&lt;br /&gt;
# Add translations&lt;br /&gt;
# Include the translations in the installation&lt;br /&gt;
&lt;br /&gt;
== The overall process ==&lt;br /&gt;
&lt;br /&gt;
From the source code, using a command line tool, we will generate a &amp;quot;.pot&amp;quot; file. It is plain text file containing all strings that need translation in the project. This .pot file only needs to be generated/recreated when the strings change in the code (and _not_ in every build!). There is only one .pot file per project.&lt;br /&gt;
&lt;br /&gt;
Then, from the .pot files and using another command line tool, we will generate the .po files for each language. There is one .po file per language, and it is the file that the translators need to complete. Both .pot and all .po files should be committed in the repository.&lt;br /&gt;
&lt;br /&gt;
But once your program is running, it doesn&#039;t use directly .po files, but a binary (compiled) version of them: the .mo files. These .mo files must be re-created on build time (when creating the package) and installed in the right location in the system. These are generated files, so don&#039;t commit them in the repository.&lt;br /&gt;
&lt;br /&gt;
From the code point of view, you just need to call few functions to tell gettext where are the translation files, what language do you want to use (usually the locale of the environment), and then it will use its implementation to find the right string.&lt;br /&gt;
&lt;br /&gt;
Ok, this is what we need to do. Let&#039;s code.&lt;br /&gt;
&lt;br /&gt;
== Configure gettext Define the &#039;_()&#039; function ==&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t care too much about the details, just copy this [https://garage.maemo.org/plugins/ggit/browse.php/?p=mussorgsky;a=blob;f=src/i18n.py;hb=HEAD i18n.py] file in your src/ directory (&#039;&#039;&#039;change the APP_NAME&#039;&#039;&#039; variable there!), and in every .py file in your module that needs to translate any string, add these lines at the top:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
import i18n&lt;br /&gt;
_ = i18n.language.gettext&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Done. If you are curious about what is going on there, the file has plenty of comments explaining every line.&lt;br /&gt;
&lt;br /&gt;
== Mark strings for i18n ==&lt;br /&gt;
&lt;br /&gt;
This is one of the easiest parts. Browse the source code files that show something on the screen, and wrap the visible strings (window titles, dialog titles, notifications, labels, button labels and so on) with the &#039;_()&#039; function.&lt;br /&gt;
&lt;br /&gt;
For example:&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
# import the _() function!&lt;br /&gt;
import i18n&lt;br /&gt;
_ = i18n.language.gettext&lt;br /&gt;
&lt;br /&gt;
class Example (hildon.StackableWindow):&lt;br /&gt;
&lt;br /&gt;
   def __init__ (self):&lt;br /&gt;
       hildon.StackableWindow.__init__ (self)&lt;br /&gt;
       self.set_title ( _(&amp;quot;All music&amp;quot;) )   &amp;lt;------- ADD THIS!&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
== Generate template for the translators ==&lt;br /&gt;
&lt;br /&gt;
Create a po folder in your project (usually at the same level as src/) and run the following command from the top directory of your project. You can do this inside or outside Scratchbox, there is no difference.&lt;br /&gt;
&lt;br /&gt;
 xgettext --language=Python --keyword=_ --output=po/PROJECTNAME.pot `find . -name &amp;quot;*.py&amp;quot;`&lt;br /&gt;
&lt;br /&gt;
It will parse files, written in Python, looking for strings marked with the keyword (function name) &#039;_&#039; and saving the output in a file called &#039;po/PROJECTNAME.pot&#039;. The list of files is the last argument. I like to use &amp;quot;find&amp;quot;, but you can manually put a list of files there.&lt;br /&gt;
&lt;br /&gt;
That command will generate the .pot file. Easy, isn&#039;t it?&lt;br /&gt;
&lt;br /&gt;
== How to add translations ==&lt;br /&gt;
&lt;br /&gt;
Now you want to get a translation in an specific language. You need to generate a .po for it.&lt;br /&gt;
&lt;br /&gt;
Go to the po/ folder and run this command (again, inside/outside scratchbox doesn&#039;t matter):&lt;br /&gt;
&lt;br /&gt;
 msginit --input=PROJECTNAME.pot --locale=LOCALE&lt;br /&gt;
&lt;br /&gt;
For instance, if i want a .po file for the spanish translation of my project Mussorgsky, i write:&lt;br /&gt;
&lt;br /&gt;
 msginit --input=mussorgsky.pot --locale=es_ES&lt;br /&gt;
&lt;br /&gt;
It will generate a file &amp;quot;es.po&amp;quot; and translators can/must work on that file. &lt;br /&gt;
&lt;br /&gt;
&#039;&#039;&#039;IMPORTANT&#039;&#039;&#039;: by default the generated .po file declares its charset as ASCII. This means that translations with non-ascii characters will provoke an error in the program. To solve this, set the charset to &#039;utf-8&#039;:&lt;br /&gt;
&lt;br /&gt;
 &amp;quot;Language-Team: Spanish\n&amp;quot;&lt;br /&gt;
 &amp;quot;MIME-Version: 1.0\n&amp;quot;&lt;br /&gt;
 &amp;quot;Content-Type: text/plain; charset=utf-8\n&amp;quot;  &amp;lt;--- THIS MUST BE UTF-8&lt;br /&gt;
&lt;br /&gt;
If you don&#039;t know the locale of a language, can check [http://www.roseindia.net/tutorials/I18N/locales-list.shtml this list].&lt;br /&gt;
&lt;br /&gt;
== Include translations in your installation ==&lt;br /&gt;
&lt;br /&gt;
This part is more tricky, because it depends on your build system. I&#039;ll explain how it goes with the common python &#039;distutils&#039; (what makes the usual &#039;&#039;python setup.py install&#039;&#039; command work). In distutils all the magic happens in the &#039;&#039;setup.py&#039;&#039; file.&lt;br /&gt;
&lt;br /&gt;
First of all, if in the previous steps you have added the i18n.py file to your source tree, don&#039;t forget to include it in your data_files list!&lt;br /&gt;
&lt;br /&gt;
Then, copy to the root folder of your project the file [https://garage.maemo.org/plugins/ggit/browse.php/?p=mussorgsky;a=blob;f=msgfmt.py;hb=HEAD msgfmt.py]. It is a program that translates the .po files into the binary .mo files that the application needs.&lt;br /&gt;
&lt;br /&gt;
In your setup.py file you need to add all this code. It &amp;quot;overloads&amp;quot; the default &#039;build&#039; and &#039;install&#039; instructions to include the translations in the process. Now in &#039;build&#039; time it will generate the .mo files (using the msgfmt.py we added just now), and in &#039;install&#039; time it will include the &#039;.mo&#039; files in the data_files list. The code is copied from this a [https://garage.maemo.org/plugins/ggit/browse.php/?p=mussorgsky;a=blob;f=setup.py;hb=HEAD setup.py] file.&lt;br /&gt;
&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
from distutils.core import setup&lt;br /&gt;
from distutils.core import setup&lt;br /&gt;
from distutils import cmd&lt;br /&gt;
from distutils.command.install_data import install_data as _install_data&lt;br /&gt;
from distutils.command.build import build as _build&lt;br /&gt;
&lt;br /&gt;
import msgfmt&lt;br /&gt;
import os&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
This command compiles every .po file under the po/ folder into a .mo (the .mo files will be under build/locale/)&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class build_trans(cmd.Command):&lt;br /&gt;
    description = &#039;Compile .po files into .mo files&#039;&lt;br /&gt;
    def initialize_options(self):&lt;br /&gt;
        pass&lt;br /&gt;
&lt;br /&gt;
    def finalize_options(self):&lt;br /&gt;
        pass&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        po_dir = os.path.join(os.path.dirname(os.curdir), &#039;po&#039;)&lt;br /&gt;
        for path, names, filenames in os.walk(po_dir):&lt;br /&gt;
            for f in filenames:&lt;br /&gt;
                if f.endswith(&#039;.po&#039;):&lt;br /&gt;
                    lang = f[:len(f) - 3]&lt;br /&gt;
                    src = os.path.join(path, f)&lt;br /&gt;
                    dest_path = os.path.join(&#039;build&#039;, &#039;locale&#039;, lang, &#039;LC_MESSAGES&#039;)&lt;br /&gt;
                    dest = os.path.join(dest_path, &#039;mussorgsky.mo&#039;)&lt;br /&gt;
                    if not os.path.exists(dest_path):&lt;br /&gt;
                        os.makedirs(dest_path)&lt;br /&gt;
                    if not os.path.exists(dest):&lt;br /&gt;
                        print &#039;Compiling %s&#039; % src&lt;br /&gt;
                        msgfmt.make(src, dest)&lt;br /&gt;
                    else:&lt;br /&gt;
                        src_mtime = os.stat(src)[8]&lt;br /&gt;
                        dest_mtime = os.stat(dest)[8]&lt;br /&gt;
                        if src_mtime &amp;gt; dest_mtime:&lt;br /&gt;
                            print &#039;Compiling %s&#039; % src&lt;br /&gt;
                            msgfmt.make(src, dest)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Now we append the previous command to the &#039;build&#039; command.&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class build(_build):&lt;br /&gt;
    sub_commands = _build.sub_commands + [(&#039;build_trans&#039;, None)]&lt;br /&gt;
    def run(self):&lt;br /&gt;
        _build.run(self)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Installation time: put every .mo file under build/locale in the data_files list (the list of things to be installed) and call the default &#039;install&#039; operation&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
class install_data(_install_data):&lt;br /&gt;
&lt;br /&gt;
    def run(self):&lt;br /&gt;
        for lang in os.listdir(&#039;build/locale/&#039;):&lt;br /&gt;
            lang_dir = os.path.join(&#039;share&#039;, &#039;locale&#039;, lang, &#039;LC_MESSAGES&#039;)&lt;br /&gt;
            lang_file = os.path.join(&#039;build&#039;, &#039;locale&#039;, lang, &#039;LC_MESSAGES&#039;, &#039;mussorgsky.mo&#039;)&lt;br /&gt;
            self.data_files.append( (lang_dir, [lang_file]) )&lt;br /&gt;
        _install_data.run(self)&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Finally, add the new commands in distutils...&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
cmdclass = {&lt;br /&gt;
    &#039;build&#039;: build,&lt;br /&gt;
    &#039;build_trans&#039;: build_trans,&lt;br /&gt;
    &#039;install_data&#039;: install_data,&lt;br /&gt;
}&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
And don&#039;t forget to add this in your setup function, in the setup.py&lt;br /&gt;
&amp;lt;source lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
setup(name         = &#039;your project&#039;,&lt;br /&gt;
      ...&lt;br /&gt;
     license      = &#039;GPL v2 or later&#039;,&lt;br /&gt;
     data_files   = DATA,&lt;br /&gt;
     scripts      = SCRIPTS,&lt;br /&gt;
     cmdclass     = cmdclass   &amp;lt;----- DON&#039;T FORGET THIS&lt;br /&gt;
     )&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
Ok, now everything should be ready. If you run&lt;br /&gt;
&lt;br /&gt;
 python2.5 setup.py build&lt;br /&gt;
&lt;br /&gt;
the terminal will print things like&lt;br /&gt;
&lt;br /&gt;
 compiling es.po&lt;br /&gt;
 compiling de.po&lt;br /&gt;
 ...&lt;br /&gt;
&lt;br /&gt;
Usually dpkg-buildpackage uses python2.5 setup.py build and install, so everything should work out-of-the-box with your previous package configuration.&lt;br /&gt;
&lt;br /&gt;
Feel free to complete/correct this wiki page with your own experience.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Take a look [http://www.mac-how.net/ how to uninstall applications on mac]&lt;br /&gt;
&lt;br /&gt;
[[Category:Internationalization]]&lt;br /&gt;
[[Category:Development]]&lt;br /&gt;
[[Category:HowTo]]&lt;/div&gt;</summary>
		<author><name>173.212.211.28</name></author>
	</entry>
</feed>