Coding

Differences between revisions 1 and 2
Revision 1 as of 2009-12-05 16:22:27
Size: 250
Editor: 212
Comment:
Revision 2 as of 2009-12-05 16:42:17
Size: 5990
Editor: 212
Comment: Moved content from main page
Deletions are marked like this. Additions are marked like this.
Line 4: Line 4:
'''STILL IN DRAFT STATUS'''

=== Individual programming languages ===

==== 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 using multiple graphical toolkits =====

 * Mention `gtk` and `qt`

==== 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 [[https://launchpad.net/launchpad-integration|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:

{{attachment:../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 ===

 * [[http://www.gnu.org/software/gettext/manual/gettext.html|Gettext documentation]]
 * [[http://www.gnu.org/s/libc/manual/html_node/Message-catalogs-with-gettext.html| The GNU libc documentation on Gettext]]
 * [[http://live.gnome.org/TranslationProject/DevGuidelines|GNOME l10n guidelines for developers]] and the [[http://live.gnome.org/TranslationProject|GNOME Translation Project]]
 * [[http://docs.python.org/library/gettext.html|Python gettext module documentation]]
 * [[http://www.doughellmann.com/PyMOTW/gettext/|Doug Hellmann's article on the Python gettext module]]
 * [[http://www.openi18n.org/docs/html/LI18NUX-2000-amd4.htm|LI18NUX 2000 Globalization Specification]]
 * [[http://www.openi18n.org/docs/text/LocNameGuide-V10.txt|OpenI18N Locale Name Guideline]]
 * [[http://www.linux.com/archive/feature/53781|Bill Poser's "Controlling your locale with environment variables" article]]

STILL IN DRAFT STATUS

Individual programming languages

General
  • Mention po and help/po

  • Mention where .desktop.in and other internationalizable files, etc. are recommended to go

If you are using multiple graphical toolkits
  • Mention gtk and qt

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)