If your port requires gettext
,
just set USE_GETTEXT
to yes
,
and your port will grow the dependency on devel/gettext
. The value of
USE_GETTEXT
can also specify the required
version of the libintl
library, the basic
part of gettext
, but using this
feature is strongly discouraged:
Your port should work with just the current version of
devel/gettext
.
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 WITHOUT_NLS
.
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 your port. The
most popular languages have their respective directories
listed in LOCALBASE
/share/locale/etc/mtree/BSD.local.dist
;
that is, they are a part of the base system. The directories
for many other languages are governed by the devel/gettext
port. You may want
to consult its pkg-plist
and see whether
your port is going to install a message catalog file for a
unique language.
本文及其他文件,可由此下載: ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。
若有 FreeBSD 方面疑問,請先閱讀
FreeBSD 相關文件,如不能解決的話,再洽詢
<questions@FreeBSD.org>。
關於本文件的問題,請洽詢
<doc@FreeBSD.org>。