i18n.h 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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. {0, 0} };
  77. #else
  78. #define BEGIN_STR(argLibraryName) \
  79. enum {
  80. #define ResDef(argToken,argID,argString) \
  81. argToken = argID,
  82. #define END_STR(argLibraryName) \
  83. argLibraryName ## top };
  84. #endif
  85. #endif /* COPIED_FROM_LIBADMINUTIL_RESOURCE_H */
  86. typedef res_RESOURCE_TABLE RESOURCE_TABLE;
  87. typedef res_RESOURCE_GLOBAL RESOURCE_GLOBAL;
  88. /*******************************************************************************/
  89. /*
  90. * In accordance with the recommendations in the
  91. * "Netscape Coding Standard for Server Internationalization",
  92. * the following aliases are defined for fprintf, et al., and
  93. * these aliases should be used to clearly indicate the intended
  94. * destination for output.
  95. */
  96. #define AdminFprintf fprintf
  97. #define DebugFprintf fprintf
  98. #define ClientSprintf sprintf
  99. #define AdminSprintf sprintf
  100. #define DebugSprintf sprintf
  101. #define ClientFputs fputs
  102. #define AdminFputs fputs
  103. #define DebugFputs fputs
  104. /* more #define, as needed */
  105. /*******************************************************************************/
  106. /*
  107. * Function prototypes for application and libraries
  108. */
  109. #ifdef __cplusplus
  110. extern "C"
  111. {
  112. #endif
  113. /******************************/
  114. /* XP_GetStringFromDatabase() */
  115. /******************************/
  116. NSAPI_PUBLIC
  117. extern const char*
  118. XP_GetStringFromDatabase(const char* strLibraryName,
  119. const char* strLanguage,
  120. int iToken);
  121. #ifdef __cplusplus
  122. }
  123. #endif
  124. /*******************************************************************************/
  125. /*
  126. * Function prototypes for building string database
  127. */
  128. extern int XP_MakeStringDatabase(void);
  129. /* Used to create the string database at build time; not used by the application
  130. itself. Returns 0 is successful. */
  131. extern void XP_PrintStringDatabase(void);
  132. /* DEBUG: Prints out entire string database to standard output. */
  133. /*******************************************************************************/
  134. /*
  135. * Macros to simplify calls to XP_GetStringFromDatabase
  136. * (need one argument instead of three)
  137. */
  138. #define XP_GetAdminStr(DBTTokenName) \
  139. XP_GetStringFromDatabase(LIBRARY_NAME, \
  140. "en", \
  141. DBTTokenName)
  142. /*******************************************************************************/
  143. #endif