/src/wrappers/glib/library/utilities/glib_i18n.e

http://github.com/tybor/Liberty · Specman e · 134 lines · 2 code · 47 blank · 85 comment · 0 complexity · f53cb2b32838a0aa0466de6ed6109060 MD5 · raw file

  1. deferred class GLIB_I18N
  2. -- Internationalization
  3. -- Internationalization -- gettext support macros.
  4. -- Synopsis
  5. -- #include <glib.h>
  6. -- #include <glib/gi18n.h>
  7. -- #define _ (String)
  8. -- #define Q_ (String)
  9. -- #define N_ (String)
  10. -- const gchar* g_strip_context (const gchar *msgid,
  11. -- const gchar *msgval);
  12. -- const gchar* const * g_get_language_names (void);
  13. -- Description
  14. -- GLib doesn't force any particular localization method upon its users. But since
  15. -- GLib itself is localized using the gettext() mechanism, it seems natural to offer
  16. -- the de-facto standard gettext() support macros in an easy-to-use form.
  17. -- In order to use these macros in an application, you must include glib/gi18n.h.
  18. -- For use in a library, must include glib/gi18n-lib.h after defining the
  19. -- GETTEXT_PACKAGE macro suitably for your library:
  20. -- #define GETTEXT_PACKAGE "gtk20"
  21. -- #include <glib/gi18n-lib.h>
  22. -- Details
  23. -- _()
  24. -- #define _(String)
  25. -- Marks a string for translation, gets replaced with the translated string at
  26. -- runtime.
  27. -- String : the string to be translated
  28. -- Since 2.4
  29. -- ---------------------------------------------------------------------------------
  30. -- Q_()
  31. -- #define Q_(String)
  32. -- Like _(), but applies g_strip_context() to the translation. This has the
  33. -- advantage that the string can be adorned with a prefix to guarantee uniqueness
  34. -- and provide context to the translator.
  35. -- One use case given in the gettext manual is GUI translation, where one could e.g.
  36. -- disambiguate two "Open" menu entries as "File|Open" and "Printer|Open". Another
  37. -- use case is the string "Russian" which may have to be translated differently
  38. -- depending on whether it's the name of a character set or a language. This could
  39. -- be solved by using "charset|Russian" and "language|Russian".
  40. -- String : the string to be translated, with a '|'-separated prefix which must not
  41. -- be translated
  42. -- Since 2.4
  43. -- ---------------------------------------------------------------------------------
  44. -- N_()
  45. -- #define N_(String)
  46. -- Marks a string for translation, gets replaced with the untranslated string at
  47. -- runtime. This is useful in situations where the translated strings can't be
  48. -- directly used, e.g. in string array initializers.
  49. -- {
  50. -- static const char *messages[] = {
  51. -- N_("some very meaningful message"),
  52. -- N_("and another one")
  53. -- };
  54. -- const char *string;
  55. -- ...
  56. -- string
  57. -- = index > 1 ? _("a default message") : gettext (messages[index]);
  58. -- fputs (string);
  59. -- ...
  60. -- }
  61. -- String : the string to be translated
  62. -- Since 2.4
  63. -- ---------------------------------------------------------------------------------
  64. -- g_strip_context ()
  65. -- const gchar* g_strip_context (const gchar *msgid,
  66. -- const gchar *msgval);
  67. -- An auxiliary function for gettext() support (see Q_()).
  68. -- msgid : a string
  69. -- msgval : another string
  70. -- Returns : msgval, unless msgval is identical to msgid and contains a '|'
  71. -- character, in which case a pointer to the substring of msgid after the
  72. -- first '|' character is returned.
  73. -- Since 2.4
  74. -- ---------------------------------------------------------------------------------
  75. -- g_get_language_names ()
  76. -- const gchar* const * g_get_language_names (void);
  77. -- Computes a list of applicable locale names, which can be used to e.g. construct
  78. -- locale-dependent filenames or search paths. The returned list is sorted from most
  79. -- desirable to least desirable and always contains the default locale "C".
  80. -- For example, if LANGUAGE=de:en_US, then the returned list is "de", "en_US", "en",
  81. -- "C".
  82. -- This function consults the environment variables LANGUAGE, LC_ALL, LC_MESSAGES
  83. -- and LANG to find the list of locales specified by the user.
  84. -- Returns : a NULL-terminated array of strings owned by GLib that must not be
  85. -- modified or freed.
  86. -- Since 2.6
  87. end -- class GLIB_I18N