If your port requires gettext
, set
USES= gettext
, and your port will inherit
a dependency on
devel/gettext
. Other
values for gettext
usage are listed in
Section 15.1, “Values of USES
”.
A rather common case is a port using
gettext
and configure
.
Generally, GNU configure
should be able
to locate gettext
automatically. If it
ever fails to, hints at the location of
gettext
can be passed in
CPPFLAGS
and LDFLAGS
as
follows:
Of course, the code can be more compact if there are no
more flags to pass to configure
:
Some software products allow for disabling NLS, e.g.,
through passing --disable-nls
to
configure
. In that case, your port
should use gettext
conditionally,
depending on the status of the NLS
option. For ports of low to medium complexity, you can rely
on the following idiom:
The next item on your to-do list is to arrange so that
the message catalog files are included in the packing list
conditionally. The Makefile
part of
this task is already provided by the idiom. It is explained
in the section on advanced
pkg-plist
practices. In a
nutshell, each occurrence of %%NLS%%
in
pkg-plist
will be replaced by
“@comment
” if NLS is
disabled, or by a null string if NLS is enabled.
Consequently, the lines prefixed by
%%NLS%%
will become mere comments in the
final packing list if NLS is off; otherwise the prefix will
be just left out. All you need to do now is insert
%%NLS%%
before each path to a message
catalog file in pkg-plist
. For
example:
In high complexity cases, you may need to use more advanced techniques than the recipe given here, such as dynamic packing list generation.
There is a point to note about installing message
catalog files. The target directories for them, which
reside under
,
should rarely be created and removed by a port. The most
popular languages have their respective directories listed
in
LOCALBASE
/share/locale
.
The directories for many other languages are governed by the
PORTSDIR
/Templates/BSD.local.distdevel/gettext
port.
Consult its pkg-plist
and see whether
the port is going to install a message catalog file for a
unique language.
All FreeBSD documents are available for download at http://ftp.FreeBSD.org/pub/FreeBSD/doc/
Questions that are not answered by the
documentation may be
sent to <freebsd-questions@FreeBSD.org>.
Send questions about this document to <freebsd-doc@FreeBSD.org>.