4 If you have problems understanding this README file, then please report
5 these at http://bugs.launchpad.net/intltool on Launchpad. Patches are
6 also very welcome. See HACKING for more information on submitting patches.
8 The intltool collection can be used to do these things:
10 o Extract translatable strings from various source files (.xml.in,
11 .glade, .desktop.in, .server.in, .oaf.in).
13 o Collect the extracted strings together with messages from traditional
14 source files (.c, .h) in po/$(PACKAGE).pot.
16 o Merge back the translations from .po files into .xml, .desktop and
17 .oaf files. This merge step will happen at build resp. installation
20 The intltool package has a script, intltoolize, which copies the various
21 scripts and does the other magic to your module. So users building
22 from tarballs don't need intltool, only folks building from cvs.
23 (This is modelled on gettextize.)
26 How to Use with autoconf/automake
27 ---------------------------------
28 (There is a section for non-auto* configurations below)
30 To use intltool in your module, do the following:
32 o Install intltool, and make sure that the macro it installs is
33 in aclocal's path, or do:
35 export ACLOCAL_FLAGS='-I /usr/local/share/aclocal'
37 o Add these lines to autogen.sh, after the call to gettextize:
39 echo "Running intltoolize"
40 intltoolize --copy --force --automake
42 o Add this line to configure.in near the top
44 IT_PROG_INTLTOOL([minimum required version], [no-xml])
46 o Add intltool-extract, intltool-merge, and intltool-update to
47 DISTCLEANFILES in your top-level Makefile.am.
49 o Remove po/desk.pl and po/update.* scripts. intltool-update will take
50 over their functionality.
52 At this point, translatable strings will be automatically extracted to
53 the .po files, if you make use of the following recommendations.
55 The intltool-prepare script will help you to prepare the package. It will
56 try to extract translations from existing .desktop files which will
57 become obsolete after intltoolization has taken place.
59 Examples of packages that use intltool are many of the GNOME components:
60 find them at http://git.gnome.org/.
62 Details of the IT_PROG_INTLTOOL macro
63 -------------------------------------------
65 The first parameter indicates the minimum required version. The
66 configure script will halt if the version is older than the first
69 The second parameter is to tell intltool that we don't need the
70 extended xml parsing abilities provided by the XML::Parser perl
71 module. If it is not provided, or is any value other than "no-xml",
72 then XML::Parser will be checked for by the configure script. This
73 feature is only available in intltool 0.31 or newer.
75 Extra Steps for DESKTOP Files
76 ..............................
78 This step also applies for similar files (.directory, .soundlist).
80 o Try to run intltool-prepare.
82 o Make sure intltool-prepare did find existing translations in the old
83 .desktop files and did correctly merge them into the various po/*.po
84 files. Don't forget to commit the changed .po files; otherwise
85 exiting translations will get lost!
87 o Remove old .desktop files and add new .desktop.in files.
89 o Adjust .cvsignore, .gitignore, .bzrignore or similar.
91 o Adjust Makefile.am, e.g.:
95 utilsdir = $(datadir)/gnome/apps/Utilities
96 utils_in_files = bug-buddy.desktop.in
97 utils_DATA = $(utils_in_files:.desktop.in=.desktop)
98 @INTLTOOL_DESKTOP_RULE@
102 o Add .desktop.in files to po/POTFILES.in
104 Here's a .desktop.in example:
109 _Name=Bug Report Tool
110 _Comment=Report a bug in GNOME
119 Extra Steps for GLADE Files
120 ...........................
122 o Add the .glade files you want translated to POTFILES.in
124 o Remove the intermediate *-glade.h or strings-glade.c files and drop
125 them from POTFILES.in
128 Extra Steps for SERVER Files (formerly .server)
129 .............................
131 To get server translation extraction and merging requires a few more steps:
133 o Rename your .server files to .server.in and put an
134 underscore before every value property for string attributes that should
137 o Add the new .server.in or .server.in files to POTFILES.in.
139 o Put lines like these in every Makefile.am that installs oaf files:
143 serverdir = $(libdir)/bonobo/servers
145 server_in_files = My_Server_file.server.in
146 server_DATA = $(server_in_files:.server.in=.server)
148 @INTLTOOL_SERVER_RULE@
150 EXTRA_DIST=$(server_in_files) $(server_DATA)
154 At this point, your server translations will be extracted and merged.
156 Extra Steps for XML Files (Files with .xml Extension)
157 .....................................................
159 To get xml (files with .xml extension) translation extraction
160 and merging requires these steps:
162 o Rename your .xml files to .xml.in and put an underscore before
163 every element that should be localized.
165 o Add the .xml.in files to POTFILES.in.
167 o Put lines like these in every Makefile.am that installs xml files:
171 xmldir = $(datadir)/xml
173 xml_in_files = My_xml_file.xml.in
174 xml_DATA = $(xml_in_files:.xml.in=.xml)
178 EXTRA_DIST=$(xml_in_files) $(xml_DATA)
182 At this point, your xml translations will be extracted and
183 merged. All .po files will be converted on the fly to UTF-8, and the
184 resulting XML file will have a UTF-8 effective encoding (you should
185 make sure that the encoding="..." declaration in the .xml.in file is
186 either absent or actually specifies UTF-8).
188 Previous versions of intltool generated XML files whose contents
189 were made of the contents of the .po files, without paying attention
190 to the encodings used. A single "XML" file could thus have strings in
191 different encodings. This broken behavior can be requested only by
192 using the old xml-i18n-tools API instead of the intltool one. See old
193 versions of xml-i18n-tools for documentation on how the old API worked.
197 XXX: add section for KEYS files. Works almost like XML files .
199 How to use without autoconf/automake
200 ------------------------------------
202 intltool can also be used without the auto* tools. For instance in order
203 to translate a somename.desktop.in file, you can do the following.
206 o Add a po/POTFILES.in file, including the path to the
207 somename.desktop.in file
209 Then to create the somename.desktop file all you do is:
211 $ intltool-merge po/ -d -u -c po/.intltool-merge-cache somename.desktop.in
214 You can also type intltool-merge --help for a bit more info.
216 To specify parameters for intltool-update (such as keywords or gettext
217 domain), you can use Makevars syntax as used in recent GNU gettext, by
218 putting something like the following in po/Makevars file:
221 XGETTEXT_OPTIONS = --keyword --keyword=blah
223 This will make "intltool-update -p" produce mydomain.pot, passing
224 parameters "--keyword --keyword=blah" to xgettext when extracting
227 Passing special parameters to xgettext via environment
228 ......................................................
230 If you need to add parameters passed to xgettext on a case-by-case
231 basis, you can do so using environment variable XGETTEXT_ARGS.
233 If you would run it as follows:
235 XGETTEXT_ARGS=--no-location intltool-update -p
237 You would create a PO Template file without lines which indicate
238 location of messages in the source code.
241 Changing keywords used in xgettext invocation
242 .............................................
244 If you need to change default keywords used to extract messages from
245 source code, you need to add variable XGETTEXT_KEYWORDS to
246 Makefile.in.in file inside directory where intltool-update is run
251 XGETTEXT_KEYWORDS = --keyword --keyword=P_
255 Default keywords xgettext looks for if no XGETTEXT_KEYWORDS is defined
259 Translators' comments in XML and .schemas files
260 ...............................................
262 To provide comments to translators in free-form XML or .schema files,
263 you need to precede the string to be translated with the plain XML
266 In .schemas files, comments need to be inside <default>, <short> or
267 <long> elements (i.e. they cannot be before the opening tag).