adding-packages-gettext.txt 2.8 KB

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