+2007-12-10 Matthias Clasen <mclasen@redhat.com>
+
+ * glib/gstrfuncs.h:
+ * glib/gstrfuncs.c (g_dpgettext): Change prototype to take
+ msgctxtid + offset instead of two strings, to avoid duplication
+ of string constants if the compiler/linker don't perform constant
+ suffix merging. (#502590, Christian Persch)
+
+ * glib/gi18n.h:
+ * glib/gi18n-lib.h: Adapt the definitions of C_() and Q_().
+
2007-12-09 Hans Breuer <hans@breuer.org>
* tests/gio-ls.c : (new file) a test program emulating some of 'ls'
#endif
#define _(String) dgettext (GETTEXT_PACKAGE, String)
-#define Q_(String) g_dpgettext (GETTEXT_PACKAGE, String, NULL)
+#define Q_(String) g_dpgettext (GETTEXT_PACKAGE, String, 0)
#define N_(String) (String)
-#define C_(Context,String) g_dpgettext (GETTEXT_PACKAGE, Context "\004" String, String)
+#define C_(Context,String) g_dpgettext (GETTEXT_PACKAGE, Context "\004" String, strlen (Context) + 1)
#endif /* __G_I18N_LIB_H__ */
#include <libintl.h>
#define _(String) gettext (String)
-#define Q_(String) g_dpgettext (NULL, String, NULL)
+#define Q_(String) g_dpgettext (NULL, String, 0)
#define N_(String) (String)
-#define C_(Context,String) g_dpgettext (NULL, Context "\004" String, String)
+#define C_(Context,String) g_dpgettext (NULL, Context "\004" String, strlen (Context) + 1)
#endif /* __G_I18N_H__ */
* g_dpgettext:
* @domain: the translation domain to use, or %NULL to use
* the domain set with textdomain()
- * @msgctxtid: a combined message context and message id
- * @msgid: the message id, or %NULL
+ * @msgctxtid: a combined message context and message id, separated
+ * by a \004 character
+ * @msgidoffset: the offset of the message id in @msgctxid
*
* This function is a variant of dgettext() which supports
* a disambiguating message context. GNU gettext uses the
* '\004' character to separate the message context and
- * message id in @msgctxtid. If %NULL is passed as @msgid,
- * this function also supports the older convention of using
- * '|' as a separator.
+ * message id in @msgctxtid.
+ * If 0 is passed as @msgidoffset, this function will fall back to
+ * trying to use the deprecated convention of using "|" as a separation
+ * character.
*
* Applications should normally not use this function directly,
- * but use the C_() or Q_() macros for translations with
- * context.
+ * but use the C_() macro for translations with context.
*
* Returns: The translated string
*
const gchar *
g_dpgettext (const gchar *domain,
const gchar *msgctxtid,
- const gchar *msgid)
+ gsize msgidoffset)
{
const gchar *translation;
gchar *sep;
if (translation == msgctxtid)
{
- if (msgid)
- return msgid;
+ if (msgidoffset > 0)
+ return msgctxtid + msgidoffset;
sep = strchr (msgctxtid, '|');
G_CONST_RETURN gchar *g_dpgettext (const gchar *domain,
const gchar *msgctxtid,
- const gchar *msgid);
+ gsize msgidoffset);
G_END_DECLS