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