Coding

Differences between revisions 2 and 3
Revision 2 as of 2009-12-05 16:42:17
Size: 5990
Editor: 212
Comment: Moved content from main page
Revision 3 as of 2009-12-05 16:49:56
Size: 5989
Editor: 212
Comment:
Deletions are marked like this. Additions are marked like this.
Line 6: Line 6:
=== Individual programming languages ===

=
=== Recommended directory layout ====

===== General =====
=== Recommended directory layout ===

==== General ====
Line 15: Line 13:
===== If you are using multiple graphical toolkits ===== ==== If you are supporting multiple graphical toolkits ====
Line 18: Line 16:

=== Individual programming languages ===

STILL IN DRAFT STATUS

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:

../LPI.png

Here's an example in C of how support for this library was added to Empathy:

=== modified file 'configure.ac'
--- configure.ac        2009-10-13 03:20:58 +0000
+++ configure.ac        2009-10-13 03:26:58 +0000
@@ -131,6 +131,7 @@
    gstreamer-0.10
    unique-1.0
    gnome-keyring-1 >= $KEYRING_REQUIRED
+   launchpad-integration
 ])
 
 PKG_CHECK_MODULES(LIBNOTIFY, libnotify >= $LIBNOTIFY_REQUIRED)

=== modified file 'src/empathy-main-window.c'
--- src/empathy-main-window.c   2009-10-13 03:20:58 +0000
+++ src/empathy-main-window.c   2009-10-13 18:15:41 +0000
@@ -27,6 +27,9 @@
 #include <gtk/gtk.h>
 #include <glib/gi18n.h>
 
+/* Add launchpad hooks */
+#include <launchpad-integration.h>
+
 #include <libempathy/empathy-contact.h>
 #include <libempathy/empathy-utils.h>
 #include <libempathy/empathy-account-manager.h>
@@ -1424,6 +1427,9 @@
 
        main_window_update_status (window, window->account_manager);
 
+       /* Add launchpad hooks */
+       launchpad_integration_add_ui (window->ui_manager, "/menubar/help/LaunchpadItems");
+
        return window->window;
 }
 

=== modified file 'src/empathy-main-window.ui'
--- src/empathy-main-window.ui  2009-10-13 03:19:42 +0000
+++ src/empathy-main-window.ui  2009-10-13 18:17:20 +0000
@@ -243,6 +243,7 @@
         <menu action="help">
           <menuitem action="help_contents"/>
           <menuitem action="help_debug"/>
+          <placeholder name="LaunchpadItems"/>
           <menuitem action="help_about"/>
         </menu>
       </menubar>

Additional documentation


CategoryUbuntuDevelopment CategoryTranslations

UbuntuDevelopment/Internationalisation/Coding (last edited 2010-02-18 10:50:22 by 28)