Coding
|
Size: 6402
Comment:
|
Size: 7290
Comment:
|
| Deletions are marked like this. | Additions are marked like this. |
| Line 141: | Line 141: |
| ##StartRecipeLPI | |
| Line 148: | Line 149: |
| It has bindings for several languages, for example, here's how Launchpad integration was [[Bug:508395|added to Pitivi]] in '''Python'''. | {i} Note that this only works for Ubuntu packages available in the repositories. The Launchpad integration library does not work with PPAs or other projects hosted in Launchpad. It has bindings for several languages. Some examples ==== Python with GtkBuilder ==== {{{ #!python import LaunchpadIntegration LaunchpadIntegration.set_sourcepackagename('my_app') LaunchpadIntegration.add_items(self.builder.get_object('menu_help'), 0, False, True) }}} Assuming `self.builder` is a [[http://www.pygtk.org/docs/pygtk/class-gtkbuilder.html|gtk.Builder]] object where the UI is loaded, the first argument in the `add_items` method is the widget where to add the menu items (a menu we've called 'menu_help'), the second one is their position in the menu shell, and the last two ones specify whether to show spearators on the top and bottom, respectively. Here is also another example on how Launchpad integration was [[Bug:508395|added to Pitivi]]. ==== C# ==== |
| Line 151: | Line 168: |
==== C ==== |
|
| Line 205: | Line 224: |
| ##EndRecipeLPI |
Getting Started |
Contents |
Ubuntu Development > Internationalization Guide > Coding
STILL IN DRAFT STATUS
Recommended directory layout
General
Mention po and help/po
- Mention where .desktop.in and other internationalizable files, etc. are recommended to go
If you are supporting multiple graphical toolkits
Mention gtk and qt
Individual programming languages
C application, using automake and intltool
Changes in configure.ac
GETTEXT_PACKAGE=your-application-domain-name
AC_SUBST(GETTEXT_PACKAGE)
AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", [gettext package name])
AM_GLIB_GNU_GETTEXT
# AM_GNOME_GETTEXT above substs $DATADIRNAME
# this is the directory where the *.{mo,gmo} files are installed
localedir='${prefix}/${DATADIRNAME}/locale'
AC_SUBST(localedir)
IT_PROG_INTLTOOL([0.40.0])
AC_OUTPUT([
po/Makefile.in
])
Changes in Makefile.am
General
SUBDIRS = po
If you are using Freedesktop.org desktop entries
desktopdir = $(datadir)/applications
desktop_in_files = yourappname.desktop.in
desktop_DATA = $(desktop_in_files:.desktop.in=.desktop)
@INTLTOOL_DESKTOP_RULE@
EXTRA_DIST = \
$(desktop_in_files) \
DISTCLEANFILES = \
$(desktop_DATA) \
If you are using Gconf schema files
schema_in_files = yourappname.schemas.in
schemadir = @GCONF_SCHEMA_FILE_DIR@
schema_DATA = $(schema_in_files:.schemas.in=.schemas)
@INTLTOOL_SCHEMAS_RULE@
EXTRA_DIST = \
$(schema_in_files) \
DISTCLEANFILES = \
$(schema_DATA) \- Marking the files for internationalisation:
If you are using Policykit policy files
policydir = $(YOURAPPS_POLICY_DIR)
policy_in_files = yourappname.policy.in
policy_DATA = $(policy_in_files:.policy.in=.policy)
@INTLTOOL_POLICY_RULE@
EXTRA_DIST = \
$(policy_in_files) \
DISTCLEANFILES = \
$(policy_DATA)- Marking them for internationalisation: TODO: prepare a separate section on policy files, including the snippet below
<action id="org.freedesktop.systemtoolsbackends.set">
<_description>Manage system configuration</_description>
<_message>System policy prevents modifying the configuration</_message>
<defaults>
<allow_inactive>no</allow_inactive>
<allow_active>auth_admin</allow_active>
</defaults>
</action>
Other required files
- po/LINGUAS
- po/POTFILES.in
- [optional] po/POTFILES.skip
Code changes
Enabling gettext
Marking strings for translation
- Mention gettext _()
- Mention ngettext
Python application, using automake and intltool
Python application, using pyton-distutils-extra
Translator comments
Translator credits
GTK
KDE
Launchpad
Launchpad integration library
Ubuntu applications use the Launchpad integration library to provide shortcuts to Launchpad to obtain help, report bugs and submit translations. You can see it in action in any Ubuntu application's Help menu:
Note that this only works for Ubuntu packages available in the repositories. The Launchpad integration library does not work with PPAs or other projects hosted in Launchpad.
It has bindings for several languages. Some examples
Python with GtkBuilder
Assuming self.builder is a gtk.Builder object where the UI is loaded, the first argument in the add_items method is the widget where to add the menu items (a menu we've called 'menu_help'), the second one is their position in the menu shell, and the last two ones specify whether to show spearators on the top and bottom, respectively.
Here is also another example on how Launchpad integration was added to Pitivi.
C#
There are no C# bindings at the moment but they are currently under way.
C
Here's an example in C of how support for this library was added to Empathy:
1 === modified file 'configure.ac'
2 --- configure.ac 2009-10-13 03:20:58 +0000
3 +++ configure.ac 2009-10-13 03:26:58 +0000
4 @@ -131,6 +131,7 @@
5 gstreamer-0.10
6 unique-1.0
7 gnome-keyring-1 >= $KEYRING_REQUIRED
8 + launchpad-integration
9 ])
10
11 PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= $LIBNOTIFY_REQUIRED)
12
13 === modified file 'src/empathy-main-window.c'
14 --- src/empathy-main-window.c 2009-10-13 03:20:58 +0000
15 +++ src/empathy-main-window.c 2009-10-13 18:15:41 +0000
16 @@ -27,6 +27,9 @@
17 #include <gtk/gtk.h>
18 #include <glib/gi18n.h>
19
20 +/* Add launchpad hooks */
21 +#include <launchpad-integration.h>
22 +
23 #include <libempathy/empathy-contact.h>
24 #include <libempathy/empathy-utils.h>
25 #include <libempathy/empathy-account-manager.h>
26 @@ -1424,6 +1427,9 @@
27
28 main_window_update_status (window, window->account_manager);
29
30 + /* Add launchpad hooks */
31 + launchpad_integration_add_ui (window->ui_manager, "/menubar/help/LaunchpadItems");
32 +
33 return window->window;
34 }
35
36
37 === modified file 'src/empathy-main-window.ui'
38 --- src/empathy-main-window.ui 2009-10-13 03:19:42 +0000
39 +++ src/empathy-main-window.ui 2009-10-13 18:17:20 +0000
40 @@ -243,6 +243,7 @@
41 <menu action="help">
42 <menuitem action="help_contents"/>
43 <menuitem action="help_debug"/>
44 + <placeholder name="LaunchpadItems"/>
45 <menuitem action="help_about"/>
46 </menu>
47 </menubar>
Additional documentation
GNOME l10n guidelines for developers and the GNOME Translation Project
Bill Poser's "Controlling your locale with environment variables" article
UbuntuDevelopment/Internationalisation/Coding (last edited 2010-02-18 10:50:22 by 28)