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