HowToRTL

http://aksi.mdamt.net/system/files/maemo-rtl.png

Overview

This page describe how to enable RTL layouts in Maemo Desktop. By default, the Maemo Desktop doesn't support RTL layouts for both widget layouts and text rendering. This document covers the Sardine and doesn't (fully) apply to IT-2006.

Components need update

You need to update the following components, and after that, just restart the desktop.

Posix locales

In order to use RTL locale you should have the RTL locale definitions. You can install locales-extras-arabic or locales-extras-hebrew from Locales Extras project.

Then edit /etc/osso-af-init/locale to reflect your locale. Change the LANG and LC_MESSAGES there.

Put a symbolic link from /usr/share/locale/en_GB to /usr/share/locale/ar (for Arabic) or /usr/share/locale/he (for Hebrew) so it will use English translations as a fallback (except you have a full translation installed).

Pango

Pango shipped in the latest Sardine (w01/2007) doesn't support RTL text rendering. The Arabic and Hebrew shaper are not included in the distribution as they are disabled after the freetype component was upgraded (Pango uses old internal data of freetype in it's opentype module (which apparently needed by those shapers), which are no longer available).

At least version 1.8.1-1osso10 works. So you have to downgrade.

Gtk+ RTL initialization

A translation file is needed for the RTL locale to get Gtk+ knows that it should render the widget in RTL fashion. Prepare a blank text file and fill it with:

# Compile this to gtk20.mo and put in /usr/share/yourlocale/LC_MESSAGES
#
# Copyright (C) 2006 Nokia Corporation.
#
msgid ""
msgstr ""
"Project-Id-Version: gtk\n"
"Report-Msgid-Bugs-To: mohammad.anwari@nokia.com\n"
"POT-Creation-Date: 2006.06.22 12:40+0300\n"
"PO-Revision-Date: 2006.06.22 12:40+0300\n"
"Last-Translator:\n"
"Language-Team: ar\n"
"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"

msgid "default:LTR"
msgstr "default:RTL"

Save it as gtk20.po, then do msgfmt -cv gtk20.po -o gtk20.mo. The resulting file, gtk20.mo need to be moved to /usr/share/locale/<your-locale>/LC_MESSAGES directory.

Hildon Widgets

Patch attached here is needed to get the Hildon widgets to be RTL aware. Warning: the patch is probably incomplete as it is not yet fully tested.

Maemo Desktop

Patch attached here is needed to get the Maemo Desktop to be RTL aware. Warning: the patch is probably incomplete as it is not yet fully tested.

You also need to remove the background file in ~/.osso/hildon-home/hildon_home_bg_user.png so next time you start the desktop, the Maemo Desktop will regenerate the background. Please note that this file is needed to be removed eact time you change the locale to RTL to non-RTL or vice versa.

Themes

You need to create a new file (possibly by just copying the files, then modify them) for each theme described below. Then whenever you start the desktop with RTL locale you should switch the theme by pointing the correct theme file.

As the widgets use graphics extensively, you need basically to flip them horisontally. You can pick the ones need flipping. If you use shadows much in your theme then possibly it's necessary to flip most of the graphics so the shadows also in correct position after the flipping. You also may not want to flip the dialog frame images if they are really symmetrical.

Put the flipped graphics files to different name or different path, for example, to images/rtl directory, so you can easily distinguish them.

Matchbox theme

Copy your theme.xml file in the theme directory to theme-rtl.xml and move the original theme.xml to theme-ltr.xml.

Then modify the theme-rtl.xml by fixing the correct file names for flipped images. Probably you don't need to touch the frames images, and just modify these pixmap ids: * titlebarclosebutton * titlebarclosebuttonpressed * titlebarminimizebutton * titlebarminimizebuttonpressed * applicationtopbararea

Then modify the x coordinates for the main frame, adjust them so it will look nice.

To activate it, put a symbolic link from theme-rtl.xml to theme.xml. If you need to go back to non-RTL locale then point the symbolic link to theme-ltr.xml instead.

Sample theme (modified from Plankton) is available here: http://aksi.mdamt.net/node/172

Gtk+ theme

TommiKomulainen: If all the gtkrc change needs to achieve (widget implementation should be handling the mirroring itself) is to use 'qgn_foo-rtl.png' or 'rtl/qgn_foo.png' instead of 'qgn_foo.png' then I think we should consider modifying the theme engine to pick the alternate file based on the text direction. It could reduce parallel gtkrc files into nothing, or a single-line addition per file in current gtkrc for the places where different graphics are needed for RTL.

Copy your gtkrc and gtkrc.maemo-af-desktop files in the theme directory and give prefix according to your RTL locale id. For example, if your locale is ar_JO then copy the files to gtkrc.ar and gtkrc.maemo-af-desktop.ar respectively. Then modify the copied files by editing the path to graphics files that you have flipped. For some arrow styles, the Gtk+ will automatically switch them. For example when rendering "left" arrow, it picks the "right" arrow and render it. So you need not to use the flipped images here.

It's also advisable to have the style name different from the original name, possibly by having them prefixed with your locale or simply with "rtl" prefix, so it would be possible to mix the RTL theme and non-RTL theme definitions.

style "style-name-rtl"
{
...
}

class "SomeWidget" style "style-name-rtl"

To activate the theme, just edit ~/.osso/current-gtk-theme and ~/.osso/current-gtk-theme.maemo-af-desktop files and put correct path to your RTL rc files there. The file contents would look like this:

#include "/usr/share/themes/plankton/gtk-2.0/gtkrc"
include "/usr/share/themes/plankton/gtk-2.0/gtkrc.ar"

When you want to go back to non RTL locale then just remove the hash mark on the first line and put the hash mark on the second line.

Actually, Gtk+ can picks up the correct rtl theme without editing the files above, if you set the LANG and LC_MESSAGES to an RTL locale. But if you only want to have the RTL for LC_MESSAGES, it won't work.

Icon

You need also to flip the /usr/share/icons/hicolor/26x26/hildon/qgn_list_tasknavigator_appswitcher.png file and give it named as /usr/share/icons/hicolor/26x26/hildon/qgn_list_tasknavigator_appswitcher_rtl.png. This icon is used by Task Navigator for the application switcher functionality. Then also remove /usr/share/icons/hicolor/icon-theme.cache otherwise you won't see the icon.


CategoryHowToDevelopment