xref: /OK3568_Linux_fs/buildroot/docs/manual/adding-packages-gettext.txt (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun// -*- mode:doc; -*-
2*4882a593Smuzhiyun// vim: set syntax=asciidoc:
3*4882a593Smuzhiyun
4*4882a593Smuzhiyun=== Gettext integration and interaction with packages
5*4882a593Smuzhiyun
6*4882a593SmuzhiyunMany packages that support internationalization use the gettext
7*4882a593Smuzhiyunlibrary. Dependencies for this library are fairly complicated and
8*4882a593Smuzhiyuntherefore, deserve some explanation.
9*4882a593Smuzhiyun
10*4882a593SmuzhiyunThe 'glibc' C library integrates a full-blown implementation of
11*4882a593Smuzhiyun'gettext', supporting translation. Native Language Support is
12*4882a593Smuzhiyuntherefore built-in in 'glibc'.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunOn the other hand, the 'uClibc' and 'musl' C libraries only provide a
15*4882a593Smuzhiyunstub implementation of the gettext functionality, which allows to
16*4882a593Smuzhiyuncompile libraries and programs using gettext functions, but without
17*4882a593Smuzhiyunproviding the translation capabilities of a full-blown gettext
18*4882a593Smuzhiyunimplementation. With such C libraries, if real Native Language Support
19*4882a593Smuzhiyunis necessary, it can be provided by the +libintl+ library of the
20*4882a593Smuzhiyun+gettext+ package.
21*4882a593Smuzhiyun
22*4882a593SmuzhiyunDue to this, and in order to make sure that Native Language Support is
23*4882a593Smuzhiyunproperly handled, packages in Buildroot that can use NLS support
24*4882a593Smuzhiyunshould:
25*4882a593Smuzhiyun
26*4882a593Smuzhiyun1. Ensure NLS support is enabled when +BR2_SYSTEM_ENABLE_NLS=y+. This
27*4882a593Smuzhiyun   is done automatically for 'autotools' packages and therefore should
28*4882a593Smuzhiyun   only be done for packages using other package infrastructures.
29*4882a593Smuzhiyun
30*4882a593Smuzhiyun1. Add +$(TARGET_NLS_DEPENDENCIES)+ to the package
31*4882a593Smuzhiyun   +<pkg>_DEPENDENCIES+ variable. This addition should be done
32*4882a593Smuzhiyun   unconditionally: the value of this variable is automatically
33*4882a593Smuzhiyun   adjusted by the core infrastructure to contain the relevant list of
34*4882a593Smuzhiyun   packages. If NLS support is disabled, this variable is empty. If
35*4882a593Smuzhiyun   NLS support is enabled, this variable contains +host-gettext+ so
36*4882a593Smuzhiyun   that tools needed to compile translation files are available on the
37*4882a593Smuzhiyun   host. In addition, if 'uClibc' or 'musl' are used, this variable
38*4882a593Smuzhiyun   also contains +gettext+ in order to get the full-blown 'gettext'
39*4882a593Smuzhiyun   implementation.
40*4882a593Smuzhiyun
41*4882a593Smuzhiyun1. If needed, add +$(TARGET_NLS_LIBS)+ to the linker flags, so that
42*4882a593Smuzhiyun   the package gets linked with +libintl+. This is generally not
43*4882a593Smuzhiyun   needed with 'autotools' packages as they usually detect
44*4882a593Smuzhiyun   automatically that they should link with +libintl+. However,
45*4882a593Smuzhiyun   packages using other build systems, or problematic autotools-based
46*4882a593Smuzhiyun   packages may need this. +$(TARGET_NLS_LIBS)+ should be added
47*4882a593Smuzhiyun   unconditionally to the linker flags, as the core automatically
48*4882a593Smuzhiyun   makes it empty or defined to +-lintl+ depending on the
49*4882a593Smuzhiyun   configuration.
50*4882a593Smuzhiyun
51*4882a593SmuzhiyunNo changes should be made to the +Config.in+ file to support NLS.
52*4882a593Smuzhiyun
53*4882a593SmuzhiyunFinally, certain packages need some gettext utilities on the target,
54*4882a593Smuzhiyunsuch as the +gettext+ program itself, which allows to retrieve
55*4882a593Smuzhiyuntranslated strings, from the command line. In such a case, the package
56*4882a593Smuzhiyunshould:
57*4882a593Smuzhiyun
58*4882a593Smuzhiyun* use +select BR2_PACKAGE_GETTEXT+ in their +Config.in+ file,
59*4882a593Smuzhiyun  indicating in a comment above that it's a runtime dependency only.
60*4882a593Smuzhiyun
61*4882a593Smuzhiyun* not add any +gettext+ dependency in the +DEPENDENCIES+ variable of
62*4882a593Smuzhiyun  their +.mk+ file.
63