summaryrefslogtreecommitdiffstats
path: root/doc/gettext_12.html
blob: e90d4cd474fd8e13619b2360e78c787fa3a98942 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
<HTML>
<HEAD>
<!-- This HTML file has been created by texi2html 1.52a
     from gettext.texi on 31 January 2002 -->

<TITLE>GNU gettext utilities - 12  The Maintainer's View</TITLE>
</HEAD>
<BODY>
Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_11.html">previous</A>, <A HREF="gettext_13.html">next</A>, <A HREF="gettext_16.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
<P><HR><P>


<H1><A NAME="SEC169" HREF="gettext_toc.html#TOC169">12  The Maintainer's View</A></H1>

<P>
The maintainer of a package has many responsibilities.  One of them
is ensuring that the package will install easily on many platforms,
and that the magic we described earlier (see section <A HREF="gettext_9.html#SEC134">9  The User's View</A>) will work
for installers and end users.

</P>
<P>
Of course, there are many possible ways by which GNU <CODE>gettext</CODE>
might be integrated in a distribution, and this chapter does not cover
them in all generality.  Instead, it details one possible approach which
is especially adequate for many free software distributions following GNU
standards, or even better, Gnits standards, because GNU <CODE>gettext</CODE>
is purposely for helping the internationalization of the whole GNU
project, and as many other good free packages as possible.  So, the
maintainer's view presented here presumes that the package already has
a <TT>`configure.in&acute;</TT> file and uses GNU Autoconf.

</P>
<P>
Nevertheless, GNU <CODE>gettext</CODE> may surely be useful for free packages
not following GNU standards and conventions, but the maintainers of such
packages might have to show imagination and initiative in organizing
their distributions so <CODE>gettext</CODE> work for them in all situations.
There are surely many, out there.

</P>
<P>
Even if <CODE>gettext</CODE> methods are now stabilizing, slight adjustments
might be needed between successive <CODE>gettext</CODE> versions, so you
should ideally revise this chapter in subsequent releases, looking
for changes.

</P>



<H2><A NAME="SEC170" HREF="gettext_toc.html#TOC170">12.1  Flat or Non-Flat Directory Structures</A></H2>

<P>
Some free software packages are distributed as <CODE>tar</CODE> files which unpack
in a single directory, these are said to be <EM>flat</EM> distributions.
Other free software packages have a one level hierarchy of subdirectories, using
for example a subdirectory named <TT>`doc/&acute;</TT> for the Texinfo manual and
man pages, another called <TT>`lib/&acute;</TT> for holding functions meant to
replace or complement C libraries, and a subdirectory <TT>`src/&acute;</TT> for
holding the proper sources for the package.  These other distributions
are said to be <EM>non-flat</EM>.

</P>
<P>
We cannot say much about flat distributions.  A flat
directory structure has the disadvantage of increasing the difficulty
of updating to a new version of GNU <CODE>gettext</CODE>.  Also, if you have
many PO files, this could somewhat pollute your single directory.
Also, GNU <CODE>gettext</CODE>'s libintl sources consist of C sources, shell
scripts, <CODE>sed</CODE> scripts and complicated Makefile rules, which don't
fit well into an existing flat structure.  For these reasons, we
recommend to use non-flat approach in this case as well.

</P>
<P>
Maybe because GNU <CODE>gettext</CODE> itself has a non-flat structure,
we have more experience with this approach, and this is what will be
described in the remaining of this chapter.  Some maintainers might
use this as an opportunity to unflatten their package structure.

</P>


<H2><A NAME="SEC171" HREF="gettext_toc.html#TOC171">12.2  Prerequisite Works</A></H2>

<P>
There are some works which are required for using GNU <CODE>gettext</CODE>
in one of your package.  These works have some kind of generality
that escape the point by point descriptions used in the remainder
of this chapter.  So, we describe them here.

</P>

<UL>
<LI>

Before attempting to use <CODE>gettextize</CODE> you should install some
other packages first.
Ensure that recent versions of GNU <CODE>m4</CODE>, GNU Autoconf and GNU
<CODE>gettext</CODE> are already installed at your site, and if not, proceed
to do this first.  If you got to install these things, beware that
GNU <CODE>m4</CODE> must be fully installed before GNU Autoconf is even
<EM>configured</EM>.

To further ease the task of a package maintainer the <CODE>automake</CODE>
package was designed and implemented.  GNU <CODE>gettext</CODE> now uses this
tool and the <TT>`Makefile&acute;</TT>s in the <TT>`intl/&acute;</TT> and <TT>`po/&acute;</TT>
therefore know about all the goals necessary for using <CODE>automake</CODE>
and <TT>`libintl&acute;</TT> in one project.

Those four packages are only needed to you, as a maintainer; the
installers of your own package and end users do not really need any of
GNU <CODE>m4</CODE>, GNU Autoconf, GNU <CODE>gettext</CODE>, or GNU <CODE>automake</CODE>
for successfully installing and running your package, with messages
properly translated.  But this is not completely true if you provide
internationalized shell scripts within your own package: GNU
<CODE>gettext</CODE> shall then be installed at the user site if the end users
want to see the translation of shell script messages.

<LI>

Your package should use Autoconf and have a <TT>`configure.in&acute;</TT> or
<TT>`configure.ac&acute;</TT> file.
If it does not, you have to learn how.  The Autoconf documentation
is quite well written, it is a good idea that you print it and get
familiar with it.

<LI>

Your C sources should have already been modified according to
instructions given earlier in this manual.  See section <A HREF="gettext_3.html#SEC13">3  Preparing Program Sources</A>.

<LI>

Your <TT>`po/&acute;</TT> directory should receive all PO files submitted to you
by the translator teams, each having <TT>`<VAR>ll</VAR>.po&acute;</TT> as a name.
This is not usually easy to get translation
work done before your package gets internationalized and available!
Since the cycle has to start somewhere, the easiest for the maintainer
is to start with absolutely no PO files, and wait until various
translator teams get interested in your package, and submit PO files.

</UL>

<P>
It is worth adding here a few words about how the maintainer should
ideally behave with PO files submissions.  As a maintainer, your role is
to authentify the origin of the submission as being the representative
of the appropriate translating teams of the Translation Project (forward
the submission to <TT>`translation@iro.umontreal.ca&acute;</TT> in case of doubt),
to ensure that the PO file format is not severely broken and does not
prevent successful installation, and for the rest, to merely put these
PO files in <TT>`po/&acute;</TT> for distribution.

</P>
<P>
As a maintainer, you do not have to take on your shoulders the
responsibility of checking if the translations are adequate or
complete, and should avoid diving into linguistic matters.  Translation
teams drive themselves and are fully responsible of their linguistic
choices for the Translation Project.  Keep in mind that translator teams are <EM>not</EM>
driven by maintainers.  You can help by carefully redirecting all
communications and reports from users about linguistic matters to the
appropriate translation team, or explain users how to reach or join
their team.  The simplest might be to send them the <TT>`ABOUT-NLS&acute;</TT> file.

</P>
<P>
Maintainers should <EM>never ever</EM> apply PO file bug reports
themselves, short-cutting translation teams.  If some translator has
difficulty to get some of her points through her team, it should not be
an option for her to directly negotiate translations with maintainers.
Teams ought to settle their problems themselves, if any.  If you, as
a maintainer, ever think there is a real problem with a team, please
never try to <EM>solve</EM> a team's problem on your own.

</P>


<H2><A NAME="SEC172" HREF="gettext_toc.html#TOC172">12.3  Invoking the <CODE>gettextize</CODE> Program</A></H2>

<P>
Some files are consistently and identically needed in every package
internationalized through GNU <CODE>gettext</CODE>.  As a matter of
convenience, the <CODE>gettextize</CODE> program puts all these files right
in your package.  This program has the following synopsis:

</P>

<PRE>
gettextize [ <VAR>option</VAR>... ] [ <VAR>directory</VAR> ]
</PRE>

<P>
and accepts the following options:

</P>
<DL COMPACT>

<DT><SAMP>`-c&acute;</SAMP>
<DD>
<DT><SAMP>`--copy&acute;</SAMP>
<DD>
Copy the needed files instead of making symbolic links.  Using links
would allow the package to always use the latest <CODE>gettext</CODE> code
available on the system, but it might disturb some mechanism the
maintainer is used to apply to the sources.  Because running
<CODE>gettextize</CODE> is easy there shouldn't be problems with using copies.

<DT><SAMP>`-f&acute;</SAMP>
<DD>
<DT><SAMP>`--force&acute;</SAMP>
<DD>
Force replacement of files which already exist.

<DT><SAMP>`--intl&acute;</SAMP>
<DD>
Install the libintl sources in a subdirectory named <TT>`intl/&acute;</TT>.
This libintl will be used to provide internationalization on systems
that don't have GNU libintl installed. If this option is omitted,
the call to <CODE>AM_GNU_GETTEXT</CODE> in <TT>`configure.in&acute;</TT> should read:
<SAMP>`AM_GNU_GETTEXT([external])&acute;</SAMP>, and internationalization will not
be enabled on systems lacking GNU gettext.

<DT><SAMP>`--no-changelog&acute;</SAMP>
<DD>
Don't update or create ChangeLog files.  By default, <CODE>gettextize</CODE>
logs all changes (file additions, modifications ans removals) in a
file called <SAMP>`ChangeLog&acute;</SAMP> in each affected directory.

<DT><SAMP>`--help&acute;</SAMP>
<DD>
Display this help and exit.

<DT><SAMP>`--version&acute;</SAMP>
<DD>
Output version information and exit.

</DL>

<P>
If <VAR>directory</VAR> is given, this is the top level directory of a
package to prepare for using GNU <CODE>gettext</CODE>.  If not given, it
is assumed that the current directory is the top level directory of
such a package.

</P>
<P>
The program <CODE>gettextize</CODE> provides the following files.  However,
no existing file will be replaced unless the option <CODE>--force</CODE>
(<CODE>-f</CODE>) is specified.

</P>

<OL>
<LI>

The <TT>`ABOUT-NLS&acute;</TT> file is copied in the main directory of your package,
the one being at the top level.  This file gives the main indications
about how to install and use the Native Language Support features
of your program.  You might elect to use a more recent copy of this
<TT>`ABOUT-NLS&acute;</TT> file than the one provided through <CODE>gettextize</CODE>,
if you have one handy.  You may also fetch a more recent copy of file
<TT>`ABOUT-NLS&acute;</TT> from Translation Project sites, and from most GNU
archive sites.

<LI>

A <TT>`po/&acute;</TT> directory is created for eventually holding
all translation files, but initially only containing the file
<TT>`po/Makefile.in.in&acute;</TT> from the GNU <CODE>gettext</CODE> distribution.
(beware the double <SAMP>`.in&acute;</SAMP> in the file name) and a few auxiliary
files. If the <TT>`po/&acute;</TT> directory already exists, it will be preserved
along with the files it contains, and only <TT>`Makefile.in.in&acute;</TT> and
the auxiliary files will be overwritten.

<LI>

Only of <SAMP>`--intl&acute;</SAMP> has been specified:
A <TT>`intl/&acute;</TT> directory is created and filled with most of the files
originally in the <TT>`intl/&acute;</TT> directory of the GNU <CODE>gettext</CODE>
distribution.  Also, if option <CODE>--force</CODE> (<CODE>-f</CODE>) is given,
the <TT>`intl/&acute;</TT> directory is emptied first.

<LI>

The <TT>`config.rpath&acute;</TT> file is copied into the directory containing
configuration support files. It is needed by the <CODE>AM_GNU_GETTEXT</CODE>
autoconf macro.

</OL>

<P>
If your site support symbolic links, <CODE>gettextize</CODE> will not
actually copy the files into your package, but establish symbolic
links instead.  This avoids duplicating the disk space needed in
all packages.  Merely using the <SAMP>`-h&acute;</SAMP> option while creating the
<CODE>tar</CODE> archive of your distribution will resolve each link by an
actual copy in the distribution archive.  So, to insist, you really
should use <SAMP>`-h&acute;</SAMP> option with <CODE>tar</CODE> within your <CODE>dist</CODE>
goal of your main <TT>`Makefile.in&acute;</TT>.

</P>
<P>
It is interesting to understand that most new files for supporting
GNU <CODE>gettext</CODE> facilities in one package go in <TT>`intl/&acute;</TT>
and <TT>`po/&acute;</TT> subdirectories.  One distinction between these two
directories is that <TT>`intl/&acute;</TT> is meant to be completely identical
in all packages using GNU <CODE>gettext</CODE>, while all newly created
files, which have to be different, go into <TT>`po/&acute;</TT>.  There is a
common <TT>`Makefile.in.in&acute;</TT> in <TT>`po/&acute;</TT>, because the <TT>`po/&acute;</TT>
directory needs its own <TT>`Makefile&acute;</TT>, and it has been designed so
it can be identical in all packages.

</P>


<H2><A NAME="SEC173" HREF="gettext_toc.html#TOC173">12.4  Files You Must Create or Alter</A></H2>

<P>
Besides files which are automatically added through <CODE>gettextize</CODE>,
there are many files needing revision for properly interacting with
GNU <CODE>gettext</CODE>.  If you are closely following GNU standards for
Makefile engineering and auto-configuration, the adaptations should
be easier to achieve.  Here is a point by point description of the
changes needed in each.

</P>
<P>
So, here comes a list of files, each one followed by a description of
all alterations it needs.  Many examples are taken out from the GNU
<CODE>gettext</CODE> 0.11 distribution itself, or from the GNU
<CODE>hello</CODE> distribution (<A HREF="http://www.franken.de/users/gnu/ke/hello">http://www.franken.de/users/gnu/ke/hello</A>
or <A HREF="http://www.gnu.franken.de/ke/hello/">http://www.gnu.franken.de/ke/hello/</A>)  You may indeed
refer to the source code of the GNU <CODE>gettext</CODE> and GNU <CODE>hello</CODE>
packages, as they are intended to be good examples for using GNU
gettext functionality.

</P>



<H3><A NAME="SEC174" HREF="gettext_toc.html#TOC174">12.4.1  <TT>`POTFILES.in&acute;</TT> in <TT>`po/&acute;</TT></A></H3>

<P>
The <TT>`po/&acute;</TT> directory should receive a file named
<TT>`POTFILES.in&acute;</TT>.  This file tells which files, among all program
sources, have marked strings needing translation.  Here is an example
of such a file:

</P>

<PRE>
# List of source files containing translatable strings.
# Copyright (C) 1995 Free Software Foundation, Inc.

# Common library files
lib/error.c
lib/getopt.c
lib/xmalloc.c

# Package source files
src/gettext.c
src/msgfmt.c
src/xgettext.c
</PRE>

<P>
Hash-marked comments and white lines are ignored.  All other lines
list those source files containing strings marked for translation
(see section <A HREF="gettext_3.html#SEC15">3.2  How Marks Appear in Sources</A>), in a notation relative to the top level
of your whole distribution, rather than the location of the
<TT>`POTFILES.in&acute;</TT> file itself.

</P>


<H3><A NAME="SEC175" HREF="gettext_toc.html#TOC175">12.4.2  <TT>`LINGUAS&acute;</TT> in <TT>`po/&acute;</TT></A></H3>

<P>
The <TT>`po/&acute;</TT> directory should also receive a file named
<TT>`LINGUAS&acute;</TT>.  This file contains the list of available translations.
It is a whitespace separated list.  Hash-marked comments and white lines
are ignored.  Here is an example file:

</P>

<PRE>
# Set of available languages.
de fr
</PRE>

<P>
This example means that German and French PO files are available, so
that these languages are currently supported by your package.  If you
want to further restrict, at installation time, the set of installed
languages, this should not be done by modifying the <TT>`LINGUAS&acute;</TT> file,
but rather by using the <CODE>LINGUAS</CODE> environment variable
(see section <A HREF="gettext_9.html#SEC136">9.2  Magic for Installers</A>).

</P>


<H3><A NAME="SEC176" HREF="gettext_toc.html#TOC176">12.4.3  <TT>`Makefile&acute;</TT> pieces in <TT>`po/&acute;</TT></A></H3>

<P>
The <TT>`po/&acute;</TT> directory also has a file named <TT>`Makevars&acute;</TT>.
It can be left unmodified if your package has a single message domain
and, accordingly, a single <TT>`po/&acute;</TT> directory. Only packages which
have multiple <TT>`po/&acute;</TT> directories at different locations need to
adjust the three variables defined in <TT>`Makevars&acute;</TT>.

</P>
<P>
<TT>`po/Makevars&acute;</TT> gets inserted into the <TT>`po/Makefile&acute;</TT> when the
latter is created. At the same time, all files called <TT>`Rules-*&acute;</TT> in the
<TT>`po/&acute;</TT> directory get appended to the <TT>`po/Makefile&acute;</TT>. They present
an opportunity to add rules for special PO files to the Makefile, without
needing to mess with <TT>`po/Makefile.in.in&acute;</TT>.

</P>
<P>
GNU gettext comes with a <TT>`Rules-quot&acute;</TT> file, containing rules for
building catalogs <TT>`en@quot.po&acute;</TT> and <TT>`en@boldquot.po&acute;</TT>. The
effect of <TT>`en@quot.po&acute;</TT> is that people who set their <CODE>LANGUAGE</CODE>
environment variable to <SAMP>`en@quot&acute;</SAMP> will get messages with proper
looking symmetric Unicode quotation marks instead of abusing the ASCII
grave accent and the ASCII apostrophe for indicating quotations. To
enable this catalog, simply add <CODE>en@quot</CODE> to the <TT>`po/LINGUAS&acute;</TT>
file. The effect of <TT>`en@boldquot.po&acute;</TT> is that people who set
<CODE>LANGUAGE</CODE> to <SAMP>`en@boldquot&acute;</SAMP> will get not only proper quotation
marks, but also the quoted text will be shown in a bold font on terminals
and consoles. This catalog is useful only for command-line programs, not
GUI programs. To enable it, similarly add <CODE>en@boldquot</CODE> to the
<TT>`po/LINGUAS&acute;</TT> file.

</P>


<H3><A NAME="SEC177" HREF="gettext_toc.html#TOC177">12.4.4  <TT>`configure.in&acute;</TT> at top level</A></H3>

<P>
<TT>`configure.in&acute;</TT> or <TT>`configure.ac&acute;</TT> - this is the source from which
<CODE>autoconf</CODE> generates the <TT>`configure&acute;</TT> script.

</P>

<OL>
<LI>Declare the package and version.

This is done by a set of lines like these:


<PRE>
PACKAGE=gettext
VERSION=0.11
AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE")
AC_DEFINE_UNQUOTED(VERSION, "$VERSION")
AC_SUBST(PACKAGE)
AC_SUBST(VERSION)
</PRE>

Of course, you replace <SAMP>`gettext&acute;</SAMP> with the name of your package,
and <SAMP>`0.11&acute;</SAMP> by its version numbers, exactly as they
should appear in the packaged <CODE>tar</CODE> file name of your distribution
(<TT>`gettext-0.11.tar.gz&acute;</TT>, here).

<LI>Check for internationalization support.

Here is the main <CODE>m4</CODE> macro for triggering internationalization
support.  Just add this line to <TT>`configure.in&acute;</TT>:


<PRE>
AM_GNU_GETTEXT
</PRE>

This call is purposely simple, even if it generates a lot of configure
time checking and actions.

If you have suppressed the <TT>`intl/&acute;</TT> subdirectory by calling
<CODE>gettextize</CODE> without <SAMP>`--intl&acute;</SAMP> option, this call should read


<PRE>
AM_GNU_GETTEXT([external])
</PRE>

<LI>Have output files created.

The <CODE>AC_OUTPUT</CODE> directive, at the end of your <TT>`configure.in&acute;</TT>
file, needs to be modified in two ways:


<PRE>
AC_OUTPUT([<VAR>existing configuration files</VAR> intl/Makefile po/Makefile.in],
[<VAR>existing additional actions</VAR>])
</PRE>

The modification to the first argument to <CODE>AC_OUTPUT</CODE> asks
for substitution in the <TT>`intl/&acute;</TT> and <TT>`po/&acute;</TT> directories.
Note the <SAMP>`.in&acute;</SAMP> suffix used for <TT>`po/&acute;</TT> only.  This is because
the distributed file is really <TT>`po/Makefile.in.in&acute;</TT>.

If you have suppressed the <TT>`intl/&acute;</TT> subdirectory by calling
<CODE>gettextize</CODE> without <SAMP>`--intl&acute;</SAMP> option, then you don't need to
add <CODE>intl/Makefile</CODE> to the <CODE>AC_OUTPUT</CODE> line.

</OL>



<H3><A NAME="SEC178" HREF="gettext_toc.html#TOC178">12.4.5  <TT>`config.guess&acute;</TT>, <TT>`config.sub&acute;</TT> at top level</A></H3>

<P>
If you don't have suppressed the <TT>`intl/&acute;</TT> subdirectory,
you need to add the GNU <TT>`config.guess&acute;</TT> and <TT>`config.sub&acute;</TT> files
to your distribution.  They are needed because the <TT>`intl/&acute;</TT> directory
has platform dependent support for determining the locale's character
encoding and therefore needs to identify the platform.

</P>
<P>
You can obtain the newest version of <TT>`config.guess&acute;</TT> and
<TT>`config.sub&acute;</TT> from <TT>`ftp://ftp.gnu.org/pub/gnu/config/&acute;</TT>.
Less recent versions are also contained in the GNU <CODE>automake</CODE> and
GNU <CODE>libtool</CODE> packages.

</P>
<P>
Normally, <TT>`config.guess&acute;</TT> and <TT>`config.sub&acute;</TT> are put at the
top level of a distribution.  But it is also possible to put them in a
subdirectory, altogether with other configuration support files like
<TT>`install-sh&acute;</TT>, <TT>`ltconfig&acute;</TT>, <TT>`ltmain.sh&acute;</TT>,
<TT>`mkinstalldirs&acute;</TT> or <TT>`missing&acute;</TT>.  All you need to do, other than
moving the files, is to add the following line to your
<TT>`configure.in&acute;</TT>.

</P>

<PRE>
AC_CONFIG_AUX_DIR([<VAR>subdir</VAR>])
</PRE>



<H3><A NAME="SEC179" HREF="gettext_toc.html#TOC179">12.4.6  <TT>`aclocal.m4&acute;</TT> at top level</A></H3>

<P>
If you do not have an <TT>`aclocal.m4&acute;</TT> file in your distribution,
the simplest is to concatenate the files <TT>`codeset.m4&acute;</TT>,
<TT>`gettext.m4&acute;</TT>, <TT>`glibc21.m4&acute;</TT>, <TT>`iconv.m4&acute;</TT>, <TT>`isc-posix.m4&acute;</TT>,
<TT>`lcmessage.m4&acute;</TT>, <TT>`lib-ld.m4&acute;</TT>, <TT>`lib-link.m4&acute;</TT>,
<TT>`lib-prefix.m4&acute;</TT>, <TT>`progtest.m4&acute;</TT> from GNU <CODE>gettext</CODE>'s
<TT>`m4/&acute;</TT> directory into a single file.  If you have suppressed the
<TT>`intl/&acute;</TT> directory, only <TT>`gettext.m4&acute;</TT>, <TT>`iconv.m4&acute;</TT>,
<TT>`progtest.m4&acute;</TT> need to be concatenated.

</P>
<P>
If you already have an <TT>`aclocal.m4&acute;</TT> file, then you will have
to merge the said macro files into your <TT>`aclocal.m4&acute;</TT>.  Note that if
you are upgrading from a previous release of GNU <CODE>gettext</CODE>, you
should most probably <EM>replace</EM> the macros (<CODE>AM_GNU_GETTEXT</CODE>,
etc.), as they usually
change a little from one release of GNU <CODE>gettext</CODE> to the next.
Their contents may vary as we get more experience with strange systems
out there.

</P>
<P>
These macros check for the internationalization support functions
and related informations.  Hopefully, once stabilized, these macros
might be integrated in the standard Autoconf set, because this
piece of <CODE>m4</CODE> code will be the same for all projects using GNU
<CODE>gettext</CODE>.

</P>


<H3><A NAME="SEC180" HREF="gettext_toc.html#TOC180">12.4.7  <TT>`acconfig.h&acute;</TT> at top level</A></H3>

<P>
Earlier GNU <CODE>gettext</CODE> releases required to put definitions for
<CODE>ENABLE_NLS</CODE>, <CODE>HAVE_GETTEXT</CODE> and <CODE>HAVE_LC_MESSAGES</CODE>,
<CODE>HAVE_STPCPY</CODE>, <CODE>PACKAGE</CODE> and <CODE>VERSION</CODE> into an
<TT>`acconfig.h&acute;</TT> file.  This is not needed any more; you can remove
them from your <TT>`acconfig.h&acute;</TT> file unless your package uses them
independently from the <TT>`intl/&acute;</TT> directory.

</P>


<H3><A NAME="SEC181" HREF="gettext_toc.html#TOC181">12.4.8  <TT>`Makefile.in&acute;</TT> at top level</A></H3>

<P>
Here are a few modifications you need to make to your main, top-level
<TT>`Makefile.in&acute;</TT> file.

</P>

<OL>
<LI>

Add the following lines near the beginning of your <TT>`Makefile.in&acute;</TT>,
so the <SAMP>`dist:&acute;</SAMP> goal will work properly (as explained further down):


<PRE>
PACKAGE = @PACKAGE@
VERSION = @VERSION@
</PRE>

<LI>

Add file <TT>`ABOUT-NLS&acute;</TT> to the <CODE>DISTFILES</CODE> definition, so the file gets
distributed.

<LI>

Wherever you process subdirectories in your <TT>`Makefile.in&acute;</TT>, be sure
you also process dir subdirectories <SAMP>`intl&acute;</SAMP> and <SAMP>`po&acute;</SAMP>.  Special
rules in the <TT>`Makefiles&acute;</TT> take care for the case where no
internationalization is wanted.

If you are using Makefiles, either generated by automake, or hand-written
so they carefully follow the GNU coding standards, the effected goals for
which the new subdirectories must be handled include <SAMP>`installdirs&acute;</SAMP>,
<SAMP>`install&acute;</SAMP>, <SAMP>`uninstall&acute;</SAMP>, <SAMP>`clean&acute;</SAMP>, <SAMP>`distclean&acute;</SAMP>.

Here is an example of a canonical order of processing.  In this
example, we also define <CODE>SUBDIRS</CODE> in <CODE>Makefile.in</CODE> for it
to be further used in the <SAMP>`dist:&acute;</SAMP> goal.


<PRE>
SUBDIRS = doc intl lib src po
</PRE>

Note that you must arrange for <SAMP>`make&acute;</SAMP> to descend into the
<CODE>intl</CODE> directory before descending into other directories containing
code which make use of the <CODE>libintl.h</CODE> header file.  For this
reason, here we mention <CODE>intl</CODE> before <CODE>lib</CODE> and <CODE>src</CODE>.

<LI>

A delicate point is the <SAMP>`dist:&acute;</SAMP> goal, as both
<TT>`intl/Makefile&acute;</TT> and <TT>`po/Makefile&acute;</TT> will later assume that the
proper directory has been set up from the main <TT>`Makefile&acute;</TT>.  Here is
an example at what the <SAMP>`dist:&acute;</SAMP> goal might look like:


<PRE>
distdir = $(PACKAGE)-$(VERSION)
dist: Makefile
	rm -fr $(distdir)
	mkdir $(distdir)
	chmod 777 $(distdir)
	for file in $(DISTFILES); do \
	  ln $$file $(distdir) 2&#62;/dev/null || cp -p $$file $(distdir); \
	done
	for subdir in $(SUBDIRS); do \
	  mkdir $(distdir)/$$subdir || exit 1; \
	  chmod 777 $(distdir)/$$subdir; \
	  (cd $$subdir &#38;&#38; $(MAKE) $@) || exit 1; \
	done
	tar chozf $(distdir).tar.gz $(distdir)
	rm -fr $(distdir)
</PRE>

</OL>



<H3><A NAME="SEC182" HREF="gettext_toc.html#TOC182">12.4.9  <TT>`Makefile.in&acute;</TT> in <TT>`src/&acute;</TT></A></H3>

<P>
Some of the modifications made in the main <TT>`Makefile.in&acute;</TT> will
also be needed in the <TT>`Makefile.in&acute;</TT> from your package sources,
which we assume here to be in the <TT>`src/&acute;</TT> subdirectory.  Here are
all the modifications needed in <TT>`src/Makefile.in&acute;</TT>:

</P>

<OL>
<LI>

In view of the <SAMP>`dist:&acute;</SAMP> goal, you should have these lines near the
beginning of <TT>`src/Makefile.in&acute;</TT>:


<PRE>
PACKAGE = @PACKAGE@
VERSION = @VERSION@
</PRE>

<LI>

If not done already, you should guarantee that <CODE>top_srcdir</CODE>
gets defined.  This will serve for <CODE>cpp</CODE> include files.  Just add
the line:


<PRE>
top_srcdir = @top_srcdir@
</PRE>

<LI>

You might also want to define <CODE>subdir</CODE> as <SAMP>`src&acute;</SAMP>, later
allowing for almost uniform <SAMP>`dist:&acute;</SAMP> goals in all your
<TT>`Makefile.in&acute;</TT>.  At list, the <SAMP>`dist:&acute;</SAMP> goal below assume that
you used:


<PRE>
subdir = src
</PRE>

<LI>

The <CODE>main</CODE> function of your program will normally call
<CODE>bindtextdomain</CODE> (see see section <A HREF="gettext_3.html#SEC14">3.1  Triggering <CODE>gettext</CODE> Operations</A>), like this:


<PRE>
bindtextdomain (<VAR>PACKAGE</VAR>, LOCALEDIR);
</PRE>

To make LOCALEDIR known to the program, add the following lines to
Makefile.in:


<PRE>
datadir = @datadir@
localedir = $(datadir)/locale
DEFS = -DLOCALEDIR=\"$(localedir)\" @DEFS@
</PRE>

Note that <CODE>@datadir@</CODE> defaults to <SAMP>`$(prefix)/share&acute;</SAMP>, thus
<CODE>$(localedir)</CODE> defaults to <SAMP>`$(prefix)/share/locale&acute;</SAMP>.

<LI>

You should ensure that the final linking will use <CODE>@LIBINTL@</CODE> or
<CODE>@LTLIBINTL@</CODE> as a library.  <CODE>@LIBINTL@</CODE> is for use without
<CODE>libtool</CODE>, <CODE>@LTLIBINTL@</CODE> is for use with <CODE>libtool</CODE>. An
easy way to achieve this is to manage that it gets into <CODE>LIBS</CODE>, like
this:


<PRE>
LIBS = @LIBINTL@ @LIBS@
</PRE>

In most packages internationalized with GNU <CODE>gettext</CODE>, one will
find a directory <TT>`lib/&acute;</TT> in which a library containing some helper
functions will be build.  (You need at least the few functions which the
GNU <CODE>gettext</CODE> Library itself needs.)  However some of the functions
in the <TT>`lib/&acute;</TT> also give messages to the user which of course should be
translated, too.  Taking care of this, the support library (say
<TT>`libsupport.a&acute;</TT>) should be placed before <CODE>@LIBINTL@</CODE> and
<CODE>@LIBS@</CODE> in the above example.  So one has to write this:


<PRE>
LIBS = ../lib/libsupport.a @LIBINTL@ @LIBS@
</PRE>

<LI>

You should also ensure that directory <TT>`intl/&acute;</TT> will be searched for
C preprocessor include files in all circumstances.  So, you have to
manage so both <SAMP>`-I../intl&acute;</SAMP> and <SAMP>`-I$(top_srcdir)/intl&acute;</SAMP> will
be given to the C compiler.

<LI>

Your <SAMP>`dist:&acute;</SAMP> goal has to conform with others.  Here is a
reasonable definition for it:


<PRE>
distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
dist: Makefile $(DISTFILES)
	for file in $(DISTFILES); do \
	  ln $$file $(distdir) 2&#62;/dev/null || cp -p $$file $(distdir); \
	done
</PRE>

</OL>



<H3><A NAME="SEC183" HREF="gettext_toc.html#TOC183">12.4.10  <TT>`gettext.h&acute;</TT> in <TT>`lib/&acute;</TT></A></H3>

<P>
Internationalization of packages, as provided by GNU <CODE>gettext</CODE>, is
optional. It can be turned off in two situations:

</P>

<UL>
<LI>

When the installer has specified <SAMP>`./configure --disable-nls&acute;</SAMP>. This
can be useful when small binaries are more important than features, for
example when building utilities for boot diskettes. It can also be useful
in order to get some specific C compiler warnings about code quality with
some older versions of GCC (older than 3.0).

<LI>

When the package does not include the <CODE>intl/</CODE> subdirectory, and the
libintl.h header (with its associated libintl library, if any) is not
already installed on the system, it is preferrable that the package builds
without internationalization support, rather than to give a compilation
error.
</UL>

<P>
A C preprocessor macro can be used to detect these two cases. Usually,
when <CODE>libintl.h</CODE> was found and not explicitly disabled, the
<CODE>ENABLE_NLS</CODE> macro will be defined to 1 in the autoconf generated
configuration file (usually called <TT>`config.h&acute;</TT>). In the two negative
situations, however, this macro will not be defined, thus it will evaluate
to 0 in C preprocessor expressions.

</P>
<P>
<TT>`gettext.h&acute;</TT> is a convenience header file for conditional use of
<TT>`&#60;libintl.h&#62;&acute;</TT>, depending on the <CODE>ENABLE_NLS</CODE> macro. If
<CODE>ENABLE_NLS</CODE> is set, it includes <TT>`&#60;libintl.h&#62;&acute;</TT>; otherwise it
defines no-op substitutes for the libintl.h functions. We recommend
the use of <CODE>"gettext.h"</CODE> over direct use of <TT>`&#60;libintl.h&#62;&acute;</TT>,
so that portability to older systems is guaranteed and installers can
turn off internationalization if they want to. In the C code, you will
then write

</P>

<PRE>
#include "gettext.h"
</PRE>

<P>
instead of

</P>

<PRE>
#include &#60;libintl.h&#62;
</PRE>

<P>
The location of <CODE>gettext.h</CODE> is usually in a directory containing
auxiliary include files. In many GNU packages, there is a directory
<TT>`lib/&acute;</TT> containing helper functions; <TT>`gettext.h&acute;</TT> fits there.
In other packages, it can go into the <TT>`src&acute;</TT> directory.

</P>
<P>
Do not install the <CODE>gettext.h</CODE> file in public locations. Every
package that needs it should contain a copy of it on its own.

</P>


<H2><A NAME="SEC184" HREF="gettext_toc.html#TOC184">12.5  Autoconf macros for use in <TT>`configure.in&acute;</TT></A></H2>

<P>
GNU <CODE>gettext</CODE> installs macros for use in a package's
<TT>`configure.in&acute;</TT> or <TT>`configure.ac&acute;</TT>.
See section `Introduction' in <CITE>The Autoconf Manual</CITE>.
The primary macro is, of course, <CODE>AM_GNU_GETTEXT</CODE>.

</P>



<H3><A NAME="SEC185" HREF="gettext_toc.html#TOC185">12.5.1  AM_GNU_GETTEXT in <TT>`gettext.m4&acute;</TT></A></H3>

<P>
The <CODE>AM_GNU_GETTEXT</CODE> macro tests for the presence of the GNU gettext
function family in either the C library or a separate <CODE>libintl</CODE>
library (shared or static libraries are both supported) or in the package's
<TT>`intl/&acute;</TT> directory.

</P>
<P>
<CODE>AM_GNU_GETTEXT</CODE> accepts up to three optional arguments. The general
syntax is

</P>

<PRE>
AM_GNU_GETTEXT([<VAR>intlsymbol</VAR>], [<VAR>needsymbol</VAR>], [<VAR>intldir</VAR>])
</PRE>

<P>
<VAR>intlsymbol</VAR> can be one of <SAMP>`external&acute;</SAMP>, <SAMP>`no-libtool&acute;</SAMP>,
<SAMP>`use-libtool&acute;</SAMP>. The default (if it is not specified or empty) is
<SAMP>`no-libtool&acute;</SAMP>. <VAR>intlsymbol</VAR> should be <SAMP>`external&acute;</SAMP> for packages
with no <TT>`intl/&acute;</TT> directory, and <SAMP>`no-libtool&acute;</SAMP> or <SAMP>`use-libtool&acute;</SAMP>
for packages with an <TT>`intl/&acute;</TT> directory. If <VAR>intlsymbol</VAR> is
<SAMP>`use-libtool&acute;</SAMP>, then a libtool library
<CODE>$(top_builddir)/intl/libintl.la</CODE> will be created (shared and/or static,
depending on <CODE>--{enable,disable}-{shared,static}</CODE> and on the
presence of <CODE>AM_DISABLE_SHARED</CODE>). If <VAR>intlsymbol</VAR> is
<SAMP>`no-libtool&acute;</SAMP>, a static library
<CODE>$(top_builddir)/intl/libintl.a</CODE> will be created.

</P>
<P>
If <VAR>needsymbol</VAR> is specified and is <SAMP>`need-ngettext&acute;</SAMP>, then GNU
gettext implementations (in libc or libintl) without the <CODE>ngettext()</CODE>
function will be ignored.

</P>
<P>
<VAR>intldir</VAR> is used to find the intl libraries.  If empty, the value
<SAMP>`$(top_builddir)/intl/&acute;</SAMP> is used.

</P>
<P>
The <CODE>AM_GNU_GETTEXT</CODE> macro determines whether GNU gettext is
available and should be used. If so, it sets the <CODE>USE_NLS</CODE> variable
to <SAMP>`yes&acute;</SAMP>; it defines <CODE>ENABLE_NLS</CODE> to 1 in the autoconf
generated configuration file (usually called <TT>`config.h&acute;</TT>); it sets
the variables <CODE>LIBINTL</CODE> and <CODE>LTLIBINTL</CODE> to the linker options
for use in a Makefile (<CODE>LIBINTL</CODE> for use without libtool,
<CODE>LTLIBINTL</CODE> for use with libtool); it adds an <SAMP>`-I&acute;</SAMP> option to
<CODE>CPPFLAGS</CODE> if necessary. In the negative case, it sets
<CODE>USE_NLS</CODE> to <SAMP>`no&acute;</SAMP>; it sets <CODE>LIBINTL</CODE> and <CODE>LTLIBINTL</CODE>
to empty and doesn't change <CODE>CPPFLAGS</CODE>.

</P>
<P>
The complexities that <CODE>AM_GNU_GETTEXT</CODE> deals with are the following:

</P>

<UL>
<LI>

Some operating systems have <CODE>gettext</CODE> in the C library, for example
glibc. Some have it in a separate library <CODE>libintl</CODE>. GNU <CODE>libintl</CODE>
might have been installed as part of the GNU <CODE>gettext</CODE> package.

<LI>

GNU <CODE>libintl</CODE>, if installed, is not necessarily already in the search
path (<CODE>CPPFLAGS</CODE> for the include file search path, <CODE>LDFLAGS</CODE> for
the library search path).

<LI>

Except for glibc, the operating system's native <CODE>gettext</CODE> cannot
exploit the GNU mo files, doesn't have the necessary locale dependency
features, and cannot convert messages from the catalog's text encoding
to the user's locale encoding.

<LI>

GNU <CODE>libintl</CODE>, if installed, is not necessarily already in the
run time library search path. To avoid the need for setting an environment
variable like <CODE>LD_LIBRARY_PATH</CODE>, the macro adds the appropriate
run time search path options to the <CODE>LIBINTL</CODE> and <CODE>LTLIBINTL</CODE>
variables. This works on most systems, but not on some operating systems
with limited shared library support, like SCO.

<LI>

GNU <CODE>libintl</CODE> relies on POSIX <CODE>iconv</CODE>. The macro checks for
linker options needed to use iconv and appends them to the <CODE>LIBINTL</CODE>
and <CODE>LTLIBINTL</CODE> variables.
</UL>



<H3><A NAME="SEC186" HREF="gettext_toc.html#TOC186">12.5.2  AM_ICONV in <TT>`iconv.m4&acute;</TT></A></H3>

<P>
The <CODE>AM_ICONV</CODE> macro tests for the presence of the POSIX
<CODE>iconv</CODE> function family in either the C library or a separate
<CODE>libiconv</CODE> library. If found, it sets the <CODE>am_cv_func_iconv</CODE>
variable to <SAMP>`yes&acute;</SAMP>; it defines <CODE>HAVE_ICONV</CODE> to 1 in the autoconf
generated configuration file (usually called <TT>`config.h&acute;</TT>); it defines
<CODE>ICONV_CONST</CODE> to <SAMP>`const&acute;</SAMP> or to empty, depending on whether the
second argument of <CODE>iconv()</CODE> is of type <SAMP>`const char **&acute;</SAMP> or
<SAMP>`char **&acute;</SAMP>; it sets the variables <CODE>LIBICONV</CODE> and
<CODE>LTLIBICONV</CODE> to the linker options for use in a Makefile
(<CODE>LIBICONV</CODE> for use without libtool, <CODE>LTLIBICONV</CODE> for use with
libtool); it adds an <SAMP>`-I&acute;</SAMP> option to <CODE>CPPFLAGS</CODE> if
necessary. If not found, it sets <CODE>LIBICONV</CODE> and <CODE>LTLIBICONV</CODE> to
empty and doesn't change <CODE>CPPFLAGS</CODE>.

</P>
<P>
The complexities that <CODE>AM_ICONV</CODE> deals with are the following:

</P>

<UL>
<LI>

Some operating systems have <CODE>iconv</CODE> in the C library, for example
glibc. Some have it in a separate library <CODE>libiconv</CODE>, for example
OSF/1 or FreeBSD. Regardless of the operating system, GNU <CODE>libiconv</CODE>
might have been installed. In that case, it should be used instead of the
operating system's native <CODE>iconv</CODE>.

<LI>

GNU <CODE>libiconv</CODE>, if installed, is not necessarily already in the search
path (<CODE>CPPFLAGS</CODE> for the include file search path, <CODE>LDFLAGS</CODE> for
the library search path).

<LI>

GNU <CODE>libiconv</CODE> is binary incompatible with some operating system's
native <CODE>iconv</CODE>, for example on FreeBSD.  Use of an <TT>`iconv.h&acute;</TT>
and <TT>`libiconv.so&acute;</TT> that don't fit together would produce program
crashes.

<LI>

GNU <CODE>libiconv</CODE>, if installed, is not necessarily already in the
run time library search path. To avoid the need for setting an environment
variable like <CODE>LD_LIBRARY_PATH</CODE>, the macro adds the appropriate
run time search path options to the <CODE>LIBICONV</CODE> variable. This works
on most systems, but not on some operating systems with limited shared
library support, like SCO.
</UL>

<P>
<TT>`iconv.m4&acute;</TT> is distributed with the GNU gettext package because
<TT>`gettext.m4&acute;</TT> relies on it.

</P>
<P><HR><P>
Go to the <A HREF="gettext_1.html">first</A>, <A HREF="gettext_11.html">previous</A>, <A HREF="gettext_13.html">next</A>, <A HREF="gettext_16.html">last</A> section, <A HREF="gettext_toc.html">table of contents</A>.
</BODY>
</HTML>