doc/reference/libpurple/plugin_i18n.xml

Sun, 20 Oct 2013 15:11:49 +0530

author
Ankit Vani <a@nevitus.org>
date
Sun, 20 Oct 2013 15:11:49 +0530
branch
soc.2013.gobjectification.plugins
changeset 36905
d256e7a2ec4c
parent 36900
doc/reference/libpurple/plugin-i18n.dox@423fbe5e5289
child 36908
c8cb7b1bcb14
permissions
-rw-r--r--

Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
The contents of the xml files mostly still need to be refactored.

36905
d256e7a2ec4c Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
Ankit Vani <a@nevitus.org>
parents: 36900
diff changeset
1 <?xml version='1.0' encoding="ISO-8859-1"?>
d256e7a2ec4c Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
Ankit Vani <a@nevitus.org>
parents: 36900
diff changeset
2 <!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.1.2//EN"
d256e7a2ec4c Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
Ankit Vani <a@nevitus.org>
parents: 36900
diff changeset
3 "http://www.oasis-open.org/docbook/xml/4.1.2/docbookx.dtd" [
d256e7a2ec4c Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
Ankit Vani <a@nevitus.org>
parents: 36900
diff changeset
4 ]>
d256e7a2ec4c Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
Ankit Vani <a@nevitus.org>
parents: 36900
diff changeset
5 <chapter id="chapter-plugin-i18n">
d256e7a2ec4c Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
Ankit Vani <a@nevitus.org>
parents: 36900
diff changeset
6 <title>Third Party Plugin Translation</title>
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
7
36905
d256e7a2ec4c Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
Ankit Vani <a@nevitus.org>
parents: 36900
diff changeset
8 <programlisting>
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
9 @section Introduction
21828
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
10 For the purpose of this document we're going to assume that your plugin:
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
11
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
12 - Is set up to use autotools. It may be possible to add translation support
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
13 without autotools, but we have no idea how. We may not want to know, either ;)
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
14 - Has an autogen.sh. You may have also called this bootstrap.sh or similar.
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
15 - Resides in a source tree that has @c configure.ac and @c Makefile.am in the
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
16 top-level directory as well as a @c src directory in which the plugin's source
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
17 is located. A @c Makefile.am should also exist in the @c src directory.
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
18
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
19 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
20 followed:
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
21
21828
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
22 - In your autogen.sh, add the following after your other utility checks:
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
23 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
24 (intltoolize --version) < /dev/null > /dev/null 2>&1 || {
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
25 echo;
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
26 echo "You must have intltool installed to compile <YOUR PLUGIN NAME>";
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
27 echo;
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
28 exit;
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
29 }
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
30 @endcode
21828
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
31 Then before your call to aclocal add:
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
32 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
33 intltoolize --force --copy
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
34 @endcode
21828
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
35 - Now edit configure.ac and add the following:
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
36 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
37 AC_PROG_INTLTOOL
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
38
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
39 GETTEXT_PACKAGE=<YOUR PLUGIN NAME>
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
40 AC_SUBST(GETTEXT_PACKAGE)
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
41 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
42
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
43 ALL_LINGUAS=""
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
44 AM_GLIB_GNU_GETTEXT
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
45 @endcode
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
46 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
47 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
48 developers. Finally add 'po/Makefile.in' to you 'AC_OUTPUT' command.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
49 - Now create a directory named 'po'.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
50 - 'cd' into the 'po' directory.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
51 - Create/edit the file 'POTFILE.in' in your favorite editor. Each line
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
52 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
53 translating (we're getting to that step). These file names should be
21828
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
54 relative to the top directory of your plugin's source tree.
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
55 - 'cd' back to the top directory of your plugin's source tree.
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
56 - Open 'Makefile.am' and add 'po' to your 'SUBDIRS' variable.
21828
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
57 - While still in the top directory of your plugin's source tree, execute
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
58 'intltool-prepare'. This will setup anything extra that intltool needs.
21828
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
59 - Fire off 'autogen.sh' and when it's completed, verify that you have a
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
60 'po/POTFILES' (notice the lack of a .in). If you do, everything should be
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
61 set on the autotools side.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
62 - Take a break, stretch your legs, smoke a cigarette, whatever, because
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
63 we're done with the autotools part.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
64 - 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
65 plugin.
16257
66f737e6b718 More renaming.
Richard Laager <rlaager@pidgin.im>
parents: 13403
diff changeset
66 - Open the file containing the PurplePluginInfo structure.
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
67 - 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
68 '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
69 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
70 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
71 #include <glib/gi18n-lib.h>
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
72 @endcode
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
73 Make sure that this include is after you include of your 'config.h',
21828
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
74 otherwise you will break your build. Also note that if you wish to
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
75 maintain compatibility with older versions of GLib, you will need to
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
76 include additional preprocessor directives, which we won't cover here.
1a1c2e5acb3f Some tweaks to grim's plugin translation documentation.
John Bailey <rekkanoryo@rekkanoryo.org>
parents: 16257
diff changeset
77 - This is where things get a bit goofy. libpurple is going to try to
16257
66f737e6b718 More renaming.
Richard Laager <rlaager@pidgin.im>
parents: 13403
diff changeset
78 translate our strings using the libpurple gettext package. So we have to
66f737e6b718 More renaming.
Richard Laager <rlaager@pidgin.im>
parents: 13403
diff changeset
79 convert them before libpurple attempts to.
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
80 - 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
81 description to NULL.
36797
997a3fb7f1c0 Updated information according to the new plugin API
Ankit Vani <a@nevitus.org>
parents: 21828
diff changeset
82 - Next, locate your 'plugin_load' function. Your name for this function
997a3fb7f1c0 Updated information according to the new plugin API
Ankit Vani <a@nevitus.org>
parents: 21828
diff changeset
83 may vary, but it's the third parameter to 'PURPLE_PLUGIN_INIT'.
997a3fb7f1c0 Updated information according to the new plugin API
Ankit Vani <a@nevitus.org>
parents: 21828
diff changeset
84 - Now add the following within your 'plugin_load' function:
13401
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
85 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
86 #ifdef ENABLE_NLS
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
87 bindtextdomain(GETTEXT_PACKAGE, LOCALEDIR);
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
88 bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
89 #endif /* ENABLE_NLS */
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
90
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
91 info.name = _("<YOUR PLUGIN NAME>");
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
92 info.summary = _("<YOUR PLUGIN SUMMARY>");
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
93 info.description = _("<YOUR PLUGIN DESCRIPTION>");
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
94 @endcode
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
95 Note that the _() is intentional, and that it is telling intltool that
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
96 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
97 string should only be marked for translation but should not be translated
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
98 yet.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
99 - 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
100 translation with _().
13403
e627c031c9d4 [gaim-migrate @ 15777]
Richard Laager <rlaager@pidgin.im>
parents: 13401
diff changeset
101 - 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
102 (pot file) or whatever.
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
103 - To create you po template, 'cd' to 'po' and execute:
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
104 @code
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
105 intltool-update --pot
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
106 @endcode
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
107 - 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
108 language code to the 'ALL_LINGUAS' variable in your configure.ac. Take
fc6b025671a8 [gaim-migrate @ 15775]
Gary Kramlich <grim@reaperworld.com>
parents:
diff changeset
109 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
110 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
111 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
112 able to use the translation.
36905
d256e7a2ec4c Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
Ankit Vani <a@nevitus.org>
parents: 36900
diff changeset
113
d256e7a2ec4c Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
Ankit Vani <a@nevitus.org>
parents: 36900
diff changeset
114 </programlisting>
d256e7a2ec4c Changed dox files to xml files for gtk-doc, and included them in the top-level XMLs.
Ankit Vani <a@nevitus.org>
parents: 36900
diff changeset
115 </chapter>

mercurial