changeset 16063:fa8aeab4ca5a

Hopefully prevent libpurple causing problems for 3rd party UIs if they also use gettext for i18n. Use dgettext & dngettext in libpurple to explicitly specify the text domain to use. Currently, with no split of strings for libpurple/pidgin/finch, we are using 'pidgin' as the gettext domain everywhere. Hopefully this didn't break anything.
author Stu Tomlinson <stu@nosnilmot.com>
date Wed, 11 Apr 2007 14:46:04 +0000
parents 07554cc5d090
children 5106ccf9f9f1
files libpurple/core.c libpurple/internal.h libpurple/protocols/msn/notification.c libpurple/protocols/oscar/oscar.c libpurple/protocols/toc/toc.c libpurple/util.c
diffstat 6 files changed, 22 insertions(+), 18 deletions(-) [+]
line wrap: on
line diff
--- a/libpurple/core.c	Wed Apr 11 13:38:05 2007 +0000
+++ b/libpurple/core.c	Wed Apr 11 14:46:04 2007 +0000
@@ -70,6 +70,9 @@
 	g_return_val_if_fail(ui != NULL, FALSE);
 	g_return_val_if_fail(purple_get_core() == NULL, FALSE);
 
+#ifdef ENABLE_NLS
+	bindtextdomain(PACKAGE, LOCALEDIR);
+#endif
 #ifdef _WIN32
 	wpurple_init();
 #endif
--- a/libpurple/internal.h	Wed Apr 11 13:38:05 2007 +0000
+++ b/libpurple/internal.h	Wed Apr 11 14:46:04 2007 +0000
@@ -43,7 +43,7 @@
 #ifdef ENABLE_NLS
 #  include <locale.h>
 #  include <libintl.h>
-#  define _(String) ((const char *)gettext(String))
+#  define _(String) ((const char *)dgettext(PACKAGE, String))
 #  ifdef gettext_noop
 #    define N_(String) gettext_noop (String)
 #  else
@@ -56,6 +56,7 @@
 #    define _(String) ((const char *)String)
 #  endif
 #  define ngettext(Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
+#  define dngettext(Domain, Singular, Plural, Number) ((Number == 1) ? ((const char *)Singular) : ((const char *)Plural))
 #endif
 
 #ifdef HAVE_ENDIAN_H
--- a/libpurple/protocols/msn/notification.c	Wed Apr 11 13:38:05 2007 +0000
+++ b/libpurple/protocols/msn/notification.c	Wed Apr 11 14:46:04 2007 +0000
@@ -1310,7 +1310,7 @@
 		{
 			case 1:
 				minutes = atoi(g_hash_table_lookup(table, "Arg1"));
-				g_snprintf(buf, sizeof(buf), ngettext(
+				g_snprintf(buf, sizeof(buf), dngettext(PACKAGE, 
 							"The MSN server will shut down for maintenance "
 							"in %d minute. You will automatically be "
 							"signed out at that time.  Please finish any "
--- a/libpurple/protocols/oscar/oscar.c	Wed Apr 11 13:38:05 2007 +0000
+++ b/libpurple/protocols/oscar/oscar.c	Wed Apr 11 14:46:04 2007 +0000
@@ -2558,7 +2558,7 @@
 	switch(reason) {
 		case 0: /* Invalid (0) */
 			buf = g_strdup_printf(
-				   ngettext(
+				   dngettext(PACKAGE, 
 				   "You missed %hu message from %s because it was invalid.",
 				   "You missed %hu messages from %s because they were invalid.",
 				   nummissed),
@@ -2567,7 +2567,7 @@
 			break;
 		case 1: /* Message too large */
 			buf = g_strdup_printf(
-				   ngettext(
+				   dngettext(PACKAGE, 
 				   "You missed %hu message from %s because it was too large.",
 				   "You missed %hu messages from %s because they were too large.",
 				   nummissed),
@@ -2576,7 +2576,7 @@
 			break;
 		case 2: /* Rate exceeded */
 			buf = g_strdup_printf(
-				   ngettext(
+				   dngettext(PACKAGE, 
 				   "You missed %hu message from %s because the rate limit has been exceeded.",
 				   "You missed %hu messages from %s because the rate limit has been exceeded.",
 				   nummissed),
@@ -2585,7 +2585,7 @@
 			break;
 		case 3: /* Evil Sender */
 			buf = g_strdup_printf(
-				   ngettext(
+				   dngettext(PACKAGE, 
 				   "You missed %hu message from %s because he/she was too evil.",
 				   "You missed %hu messages from %s because he/she was too evil.",
 				   nummissed),
@@ -2594,7 +2594,7 @@
 			break;
 		case 4: /* Evil Receiver */
 			buf = g_strdup_printf(
-				   ngettext(
+				   dngettext(PACKAGE, 
 				   "You missed %hu message from %s because you are too evil.",
 				   "You missed %hu messages from %s because you are too evil.",
 				   nummissed),
@@ -2603,7 +2603,7 @@
 			break;
 		default:
 			buf = g_strdup_printf(
-				   ngettext(
+				   dngettext(PACKAGE, 
 				   "You missed %hu message from %s for an unknown reason.",
 				   "You missed %hu messages from %s for an unknown reason.",
 				   nummissed),
@@ -3918,7 +3918,7 @@
 	}
 
 	secondary = g_strdup_printf(
-					ngettext("The following screen name is associated with %s",
+					dngettext(PACKAGE, "The following screen name is associated with %s",
 						 "The following screen names are associated with %s",
 						 num),
 					email);
@@ -4476,7 +4476,7 @@
 		if (infolen > od->rights.maxsiglen)
 		{
 			gchar *errstr;
-			errstr = g_strdup_printf(ngettext("The maximum profile length of %d byte "
+			errstr = g_strdup_printf(dngettext(PACKAGE, "The maximum profile length of %d byte "
 									 "has been exceeded.  It has been truncated it for you.",
 									 "The maximum profile length of %d bytes "
 									 "has been exceeded.  It has been truncated it for you.",
@@ -4526,7 +4526,7 @@
 		{
 			gchar *errstr;
 
-			errstr = g_strdup_printf(ngettext("The maximum away message length of %d byte "
+			errstr = g_strdup_printf(dngettext(PACKAGE, "The maximum away message length of %d byte "
 									 "has been exceeded.  It has been truncated for you.",
 									 "The maximum away message length of %d bytes "
 									 "has been exceeded.  It has been truncated for you.",
--- a/libpurple/protocols/toc/toc.c	Wed Apr 11 13:38:05 2007 +0000
+++ b/libpurple/protocols/toc/toc.c	Wed Apr 11 14:46:04 2007 +0000
@@ -2205,7 +2205,7 @@
 			index++;
 		}
 		g_snprintf(buf, sizeof(buf), 
-				ngettext(
+				dngettext(PACKAGE, 
 				"%s requests %s to accept %d file: %s (%.2f %s)%s%s",
 				"%s requests %s to accept %d files: %s (%.2f %s)%s%s",
 				ft->files),
--- a/libpurple/util.c	Wed Apr 11 13:38:05 2007 +0000
+++ b/libpurple/util.c	Wed Apr 11 14:46:04 2007 +0000
@@ -2932,7 +2932,7 @@
 
 	if (secs < 60)
 	{
-		return g_strdup_printf(ngettext("%d second", "%d seconds", secs), secs);
+		return g_strdup_printf(dngettext(PACKAGE, "%d second", "%d seconds", secs), secs);
 	}
 
 	days = secs / (60 * 60 * 24);
@@ -2944,7 +2944,7 @@
 
 	if (days > 0)
 	{
-		ret = g_strdup_printf(ngettext("%d day", "%d days", days), days);
+		ret = g_strdup_printf(dngettext(PACKAGE, "%d day", "%d days", days), days);
 	}
 
 	if (hrs > 0)
@@ -2952,13 +2952,13 @@
 		if (ret != NULL)
 		{
 			char *tmp = g_strdup_printf(
-					ngettext("%s, %d hour", "%s, %d hours", hrs),
+					dngettext(PACKAGE, "%s, %d hour", "%s, %d hours", hrs),
 							ret, hrs);
 			g_free(ret);
 			ret = tmp;
 		}
 		else
-			ret = g_strdup_printf(ngettext("%d hour", "%d hours", hrs), hrs);
+			ret = g_strdup_printf(dngettext(PACKAGE, "%d hour", "%d hours", hrs), hrs);
 	}
 
 	if (mins > 0)
@@ -2966,13 +2966,13 @@
 		if (ret != NULL)
 		{
 			char *tmp = g_strdup_printf(
-					ngettext("%s, %d minute", "%s, %d minutes", mins),
+					dngettext(PACKAGE, "%s, %d minute", "%s, %d minutes", mins),
 							ret, mins);
 			g_free(ret);
 			ret = tmp;
 		}
 		else
-			ret = g_strdup_printf(ngettext("%d minute", "%d minutes", mins), mins);
+			ret = g_strdup_printf(dngettext(PACKAGE, "%d minute", "%d minutes", mins), mins);
 	}
 
 	return ret;