doc/plugin-i18n.dox

Sun, 28 Oct 2007 17:17:56 +0000

author
Casey Harkins <charkins@pidgin.im>
date
Sun, 28 Oct 2007 17:17:56 +0000
branch
next.minor
changeset 21260
fdf636a9b3e7
parent 16257
66f737e6b718
child 21828
1a1c2e5acb3f
permissions
-rw-r--r--

Rolling back docklet geometry changes. These will have to wait until next
major.

13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
1 /** @page plugin-i18n Third Party Plugin Translation Support
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
2
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
3 @section Introduction
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
4 For a plugin to have translation support there are a few steps that need to
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
5 followed:
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
6
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7 - The plugin must be setup to use autotools. It may be possible to add
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
8 translation support without autotools, but I have no idea how.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 - In your autogen.sh, bootstrap.sh, or whatever you called it, add the
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
10 following after your other utility checks:
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
11 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
12 (intltoolize --version) < /dev/null > /dev/null 2>&1 || {
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
13 echo;
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
14 echo "You must have intltool installed to compile <YOUR PLUGIN NAME>";
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
15 echo;
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
16 exit;
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
17 }
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
18 @endcode
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 Then before your call aclocal add:
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
20 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21 intltoolize --force --copy
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
22 @endcode
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 - Now edit configure.ac, configure.in, or whatever you may have called it
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 and add the following:
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 AC_PROG_INTLTOOL
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 GETTEXT_PACKAGE=<YOUR PLUGIN NAME>
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 AC_SUBST(GETTEXT_PACKAGE)
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, ["$GETTEXT_PACKAGE"], [Define the gettext package to be used])
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
31
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 ALL_LINGUAS=""
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 AM_GLIB_GNU_GETTEXT
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 @endcode
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
35 The position of these macros in the file don't really matter, but if you
16257
66f737e6b718 More renaming.
Richard Laager <rlaager@pidgin.im>
parents: 13403
diff changeset
36 have issues either play around with it or feel free to ask one of the Pidgin
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 developers. Finally add 'po/Makefile.in' to you 'AC_OUTPUT' command.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38 - Now create a directory named 'po'.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 - 'cd' into the 'po' directory.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 - Create/edit the file 'POTFILE.in' in your favorite editor. Each line
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 should be the name of a file that could or does have strings marked for
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
42 translating (we're getting to that step). These file names should be
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 relative to the top directory of your plugin.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 - 'cd' back to the top directory of your plugin.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 - Open 'Makefile.am' and add 'po' to your 'SUBDIRS' variable.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 - While still in the top directory of your plugin execute
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
47 'intltool-prepare'. This will setup anything extra that intltool needs.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
48 - Fire off an 'autogen.sh' and when it's completed, verify that you have a
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 'po/POTFILES', notice the lack of a .in. If you do, everything should be
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 set on the autotools side.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 - Take a break, stretch your legs, smoke a cigarette, whatever, because
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 we're done with the autotools part.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
53 - When you're ready, 'cd' into the directory with the source files for your
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
54 plugin.
16257
66f737e6b718 More renaming.
Richard Laager <rlaager@pidgin.im>
parents: 13403
diff changeset
55 - Open the file containing the PurplePluginInfo structure.
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 - If you're not already, please make sure that you are including the
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
57 'config.h' file for you plugin. Note that 'config.h' could be whatever
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 you told autohead to use with AM_CONFIG_HEADER. Also add the following:
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
59 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
60 #include <glib/gi18n-lib.h>
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 @endcode
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 Make sure that this include is after you include of your 'config.h',
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 otherwise you will break your build.
16257
66f737e6b718 More renaming.
Richard Laager <rlaager@pidgin.im>
parents: 13403
diff changeset
64 - This is where things get a bit goofy. libpurple is going to try and
66f737e6b718 More renaming.
Richard Laager <rlaager@pidgin.im>
parents: 13403
diff changeset
65 translate our strings using the libpurple gettext package. So we have to
66f737e6b718 More renaming.
Richard Laager <rlaager@pidgin.im>
parents: 13403
diff changeset
66 convert them before libpurple attempts to.
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 - To do this, we're going to change the entries for name, summary, and
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
68 description to NULL.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
69 - Next, locate your 'init_plugin' function. Your name for this function
16257
66f737e6b718 More renaming.
Richard Laager <rlaager@pidgin.im>
parents: 13403
diff changeset
70 may vary, but it's the second parameter to 'PURPLE_INIT_PLUGIN'.
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 - Now add the following within your 'init_plugin' function:
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 #ifdef ENABLE_NLS
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
74 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
75 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
76 #endif /* ENABLE_NLS */
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
77
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
78 info.name = _("<YOUR PLUGIN NAME>");
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
79 info.summary = _("<YOUR PLUGIN SUMMARY>");
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 info.description = _("<YOUR PLUGIN DESCRIPTION>");
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
81 @endcode
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
82 Note that the _() is intentional, and that it is telling intltool that
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
83 this string should be translated. There is also N_() which says that a
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
84 string should only be marked for translation but should not be translated
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 yet.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 - Go through the rest of your code and mark all the other strings for
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 translation with _().
13403
e627c031c9d4 [gaim-migrate @ 15777]
Richard Laager <rlaager@pidgin.im>
parents: 13401
diff changeset
88 - When thats done, feel free to commit your work, create your po template
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 (pot file) or whatever.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90 - To create you po template, 'cd' to 'po' and execute:
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 intltool-update --pot
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 @endcode
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 - To add new translations to your plugin, all you have to do is add the
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 language code to the 'ALL_LINGUAS' variable in your configure.ac. Take
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 note that this list of languages should be separated by a space. After
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
97 you have added the language code to 'ALL_LINGUAS', drop the xx.po file
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 into 'po', and re-'autogen.sh'. After a full build you should now be
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 able to use the translation.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
100 */

mercurial