i18n.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. /** BEGIN COPYRIGHT BLOCK
  2. * Copyright (C) 2001 Sun Microsystems, Inc. Used by permission.
  3. * Copyright (C) 2005 Red Hat, Inc.
  4. * All rights reserved.
  5. *
  6. * License: GPL (version 3 or any later version).
  7. * See LICENSE for details.
  8. * END COPYRIGHT BLOCK **/
  9. #ifdef HAVE_CONFIG_H
  10. #include <config.h>
  11. #endif
  12. #ifndef I18N_H
  13. #define I18N_H
  14. /* Make NSAPI_PUBLIC available */
  15. #include "base/systems.h"
  16. /* This stuff was copied from libadminutil/resource.h so we could
  17. remove the dependency on adminutil which is not being open sourced
  18. this first round.
  19. */
  20. #ifndef COPIED_FROM_LIBADMINUTIL_RESOURCE_H
  21. /* Resource contains the name of the
  22. property file w/ paht information
  23. */
  24. typedef struct
  25. {
  26. char *path;
  27. char *package;
  28. void *propset;
  29. } Resource;
  30. /*******************************************************************************/
  31. /*
  32. * this table contains library name
  33. * (stored in the first string entry, with id=0),
  34. * and the id/string pairs which are used by library
  35. */
  36. typedef struct res_RESOURCE_TABLE
  37. {
  38. int id;
  39. char *str;
  40. } res_RESOURCE_TABLE;
  41. /*******************************************************************************/
  42. /*
  43. * resource global contains resource table list which is used
  44. * to generate the database.
  45. * Also used for "in memory" version of XP_GetStringFromDatabase()
  46. */
  47. typedef struct res_RESOURCE_GLOBAL
  48. {
  49. res_RESOURCE_TABLE *restable;
  50. } res_RESOURCE_GLOBAL;
  51. /*******************************************************************************/
  52. /*
  53. * Define the ResDef macro to simplify the maintenance of strings which are to
  54. * be added to the library or application header file (dbtxxx.h). This enables
  55. * source code to refer to the strings by theit TokenNames, and allows the
  56. * strings to be stored in the database.
  57. *
  58. * Usage: ResDef(TokenName,TokenValue,String)
  59. *
  60. * Example: ResDef(DBT_HelloWorld_, \
  61. * 1,"Hello, World!")
  62. * ResDef(DBT_TheCowJumpedOverTheMoon_, \
  63. * 2,"The cow jumped over the moon.")
  64. * ResDef(DBT_TheValueOfPiIsAbout31415926536_, \
  65. * 3,"The value of PI is about 3.1415926536."
  66. *
  67. * RESOURCE_STR is used by makstrdb.c only. It is not used by getstrdb.c or
  68. * in library or application source code.
  69. */
  70. #ifdef RESOURCE_STR
  71. #define BEGIN_STR(argLibraryName) \
  72. RESOURCE_TABLE argLibraryName[] = {{0, #argLibraryName},
  73. #define ResDef(argToken, argID, argString) \
  74. {argID, argString},
  75. #define END_STR(argLibraryName) \
  76. { \
  77. 0, 0 \
  78. } \
  79. } \
  80. ;
  81. #else
  82. #define BEGIN_STR(argLibraryName) \
  83. enum \
  84. {
  85. #define ResDef(argToken, argID, argString) \
  86. argToken = argID,
  87. #define END_STR(argLibraryName) \
  88. argLibraryName##top \
  89. } \
  90. ;
  91. #endif
  92. #endif /* COPIED_FROM_LIBADMINUTIL_RESOURCE_H */
  93. typedef res_RESOURCE_TABLE RESOURCE_TABLE;
  94. typedef res_RESOURCE_GLOBAL RESOURCE_GLOBAL;
  95. /*******************************************************************************/
  96. /*
  97. * In accordance with the recommendations in the
  98. * "Netscape Coding Standard for Server Internationalization",
  99. * the following aliases are defined for fprintf, et al., and
  100. * these aliases should be used to clearly indicate the intended
  101. * destination for output.
  102. */
  103. #define AdminFprintf fprintf
  104. #define DebugFprintf fprintf
  105. #define ClientSprintf sprintf
  106. #define AdminSprintf sprintf
  107. #define DebugSprintf sprintf
  108. #define ClientFputs fputs
  109. #define AdminFputs fputs
  110. #define DebugFputs fputs
  111. /* more #define, as needed */
  112. /*******************************************************************************/
  113. /*
  114. * Function prototypes for application and libraries
  115. */
  116. #ifdef __cplusplus
  117. extern "C" {
  118. #endif
  119. /******************************/
  120. /* XP_GetStringFromDatabase() */
  121. /******************************/
  122. NSAPI_PUBLIC
  123. extern const char *
  124. XP_GetStringFromDatabase(const char *strLibraryName,
  125. const char *strLanguage,
  126. int iToken);
  127. #ifdef __cplusplus
  128. }
  129. #endif
  130. /*******************************************************************************/
  131. /*
  132. * Function prototypes for building string database
  133. */
  134. extern int XP_MakeStringDatabase(void);
  135. /* Used to create the string database at build time; not used by the application
  136. itself. Returns 0 is successful. */
  137. extern void XP_PrintStringDatabase(void);
  138. /* DEBUG: Prints out entire string database to standard output. */
  139. /*******************************************************************************/
  140. /*
  141. * Macros to simplify calls to XP_GetStringFromDatabase
  142. * (need one argument instead of three)
  143. */
  144. #define XP_GetAdminStr(DBTTokenName) \
  145. XP_GetStringFromDatabase(LIBRARY_NAME, \
  146. "en", \
  147. DBTTokenName)
  148. /*******************************************************************************/
  149. #endif