libintl.h 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. /* Message catalogs for internationalization.
  2. Copyright (C) 1995-2020 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. This file is derived from the file libgettext.h in the GNU gettext package.
  5. The GNU C Library is free software; you can redistribute it and/or
  6. modify it under the terms of the GNU Lesser General Public
  7. License as published by the Free Software Foundation; either
  8. version 2.1 of the License, or (at your option) any later version.
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. Lesser General Public License for more details.
  13. You should have received a copy of the GNU Lesser General Public
  14. License along with the GNU C Library; if not, see
  15. <https://www.gnu.org/licenses/>. */
  16. #ifndef _LIBINTL_H
  17. #define _LIBINTL_H 1
  18. #include <features.h>
  19. /* We define an additional symbol to signal that we use the GNU
  20. implementation of gettext. */
  21. #define __USE_GNU_GETTEXT 1
  22. /* Provide information about the supported file formats. Returns the
  23. maximum minor revision number supported for a given major revision. */
  24. #define __GNU_GETTEXT_SUPPORTED_REVISION(major) \
  25. ((major) == 0 ? 1 : -1)
  26. __BEGIN_DECLS
  27. /* Look up MSGID in the current default message catalog for the current
  28. LC_MESSAGES locale. If not found, returns MSGID itself (the default
  29. text). */
  30. extern char *gettext (const char *__msgid)
  31. __THROW __attribute_format_arg__ (1);
  32. /* Look up MSGID in the DOMAINNAME message catalog for the current
  33. LC_MESSAGES locale. */
  34. extern char *dgettext (const char *__domainname, const char *__msgid)
  35. __THROW __attribute_format_arg__ (2);
  36. extern char *__dgettext (const char *__domainname, const char *__msgid)
  37. __THROW __attribute_format_arg__ (2);
  38. /* Look up MSGID in the DOMAINNAME message catalog for the current CATEGORY
  39. locale. */
  40. extern char *dcgettext (const char *__domainname,
  41. const char *__msgid, int __category)
  42. __THROW __attribute_format_arg__ (2);
  43. extern char *__dcgettext (const char *__domainname,
  44. const char *__msgid, int __category)
  45. __THROW __attribute_format_arg__ (2);
  46. /* Similar to `gettext' but select the plural form corresponding to the
  47. number N. */
  48. extern char *ngettext (const char *__msgid1, const char *__msgid2,
  49. unsigned long int __n)
  50. __THROW __attribute_format_arg__ (1) __attribute_format_arg__ (2);
  51. /* Similar to `dgettext' but select the plural form corresponding to the
  52. number N. */
  53. extern char *dngettext (const char *__domainname, const char *__msgid1,
  54. const char *__msgid2, unsigned long int __n)
  55. __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3);
  56. /* Similar to `dcgettext' but select the plural form corresponding to the
  57. number N. */
  58. extern char *dcngettext (const char *__domainname, const char *__msgid1,
  59. const char *__msgid2, unsigned long int __n,
  60. int __category)
  61. __THROW __attribute_format_arg__ (2) __attribute_format_arg__ (3);
  62. /* Set the current default message catalog to DOMAINNAME.
  63. If DOMAINNAME is null, return the current default.
  64. If DOMAINNAME is "", reset to the default of "messages". */
  65. extern char *textdomain (const char *__domainname) __THROW;
  66. /* Specify that the DOMAINNAME message catalog will be found
  67. in DIRNAME rather than in the system locale data base. */
  68. extern char *bindtextdomain (const char *__domainname,
  69. const char *__dirname) __THROW;
  70. /* Specify the character encoding in which the messages from the
  71. DOMAINNAME message catalog will be returned. */
  72. extern char *bind_textdomain_codeset (const char *__domainname,
  73. const char *__codeset) __THROW;
  74. /* Optimized version of the function above. */
  75. #if defined __OPTIMIZE__ && !defined __cplusplus
  76. /* We need NULL for `gettext'. */
  77. # define __need_NULL
  78. # include <stddef.h>
  79. /* We need LC_MESSAGES for `dgettext'. */
  80. # include <locale.h>
  81. /* These must be macros. Inlined functions are useless because the
  82. `__builtin_constant_p' predicate in dcgettext would always return
  83. false. */
  84. # define gettext(msgid) dgettext (NULL, msgid)
  85. # define dgettext(domainname, msgid) \
  86. dcgettext (domainname, msgid, LC_MESSAGES)
  87. # define ngettext(msgid1, msgid2, n) dngettext (NULL, msgid1, msgid2, n)
  88. # define dngettext(domainname, msgid1, msgid2, n) \
  89. dcngettext (domainname, msgid1, msgid2, n, LC_MESSAGES)
  90. #endif /* Optimizing. */
  91. __END_DECLS
  92. #endif /* libintl.h */