# HG changeset patch
# Node ID 1ecefe4fe4ae
# Parent  e0a24938f214
diff --git a/finch/libfinch.c b/finch/libfinch.c
--- a/finch/libfinch.c
+++ b/finch/libfinch.c
@@ -96,15 +96,16 @@
 		{NULL}
 	};
 
-	bindtextdomain(PACKAGE, PURPLE_LOCALEDIR);
-	bind_textdomain_codeset(PACKAGE, "UTF-8");
-	textdomain(PACKAGE);
+	bindtextdomain(GETTEXT_PACKAGE, purple_get_locale_dir());
+	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+	textdomain(GETTEXT_PACKAGE);
 
 	setlocale(LC_ALL, "");
 
 	context = g_option_context_new(NULL);
 	g_option_context_set_summary(context, DISPLAY_VERSION);
-	g_option_context_add_main_entries(context, option_entries, PACKAGE);
+	g_option_context_add_main_entries(context, option_entries,
+	                                  GETTEXT_PACKAGE);
 
 	g_option_context_add_group(context, purple_get_option_group());
 	g_option_context_add_group(context, gplugin_get_option_group());
diff --git a/libpurple/core.h b/libpurple/core.h
--- a/libpurple/core.h
+++ b/libpurple/core.h
@@ -115,6 +115,20 @@
 PURPLE_AVAILABLE_IN_ALL
 PurpleUi *purple_core_get_ui(void);
 
+/**
+ * purple_get_local_dir:
+ *
+ * Gets the search directory for translations.
+ *
+ * This can be overridden by the `PURPLE_LOCALE_DIR` environment variable.
+ *
+ * Returns: The directory where translations should searched for.
+ *
+ * Since: 3.0.0
+ */
+PURPLE_AVAILABLE_IN_ALL
+const char *purple_get_locale_dir(void);
+
 G_END_DECLS
 
 #endif /* PURPLE_CORE_H */
diff --git a/libpurple/core.c b/libpurple/core.c
--- a/libpurple/core.c
+++ b/libpurple/core.c
@@ -101,7 +101,7 @@
 	g_return_val_if_fail(PURPLE_IS_UI(ui), FALSE);
 	g_return_val_if_fail(purple_get_core() == NULL, FALSE);
 
-	bindtextdomain(PACKAGE, PURPLE_LOCALEDIR);
+	bindtextdomain(GETTEXT_PACKAGE, purple_get_locale_dir());
 
 #ifdef _WIN32
 	wpurple_init();
@@ -309,3 +309,19 @@
 purple_core_get_ui(void) {
 	return _core->ui;
 }
+
+const char *
+purple_get_locale_dir(void) {
+	const char *locale_dir = NULL;
+
+	locale_dir = g_getenv("PURPLE_LOCALE_DIR");
+	if(!purple_strempty(locale_dir)) {
+		return locale_dir;
+	}
+
+#ifdef _WIN32
+	return wpurple_locale_dir();
+#else
+	return PURPLE_LOCALEDIR;
+#endif
+}
diff --git a/libpurple/protocols/jabber/jabber.c b/libpurple/protocols/jabber/jabber.c
--- a/libpurple/protocols/jabber/jabber.c
+++ b/libpurple/protocols/jabber/jabber.c
@@ -2900,7 +2900,7 @@
 	if (ui)
 		ui_name = purple_ui_get_name(ui);
 	if (ui_name == NULL)
-		ui_name = PACKAGE;
+		ui_name = GETTEXT_PACKAGE;
 
 	jabber_add_identity("client", type, NULL, ui_name);
 
diff --git a/libpurple/util.c b/libpurple/util.c
--- a/libpurple/util.c
+++ b/libpurple/util.c
@@ -322,9 +322,12 @@
 	char *ret = NULL;
 	guint days, hrs, mins;
 
-	if (secs < 60)
-	{
-		return g_strdup_printf(dngettext(PACKAGE, "%d second", "%d seconds", secs), secs);
+	if(secs < 60) {
+		const char *format;
+
+		format = dngettext(GETTEXT_PACKAGE, "%d second", "%d seconds", secs);
+
+		return g_strdup_printf(format, secs);
 	}
 
 	days = secs / (60 * 60 * 24);
@@ -334,37 +337,52 @@
 	mins = secs / 60;
 	/* secs = secs % 60; */
 
-	if (days > 0)
-	{
-		ret = g_strdup_printf(dngettext(PACKAGE, "%d day", "%d days", days), days);
+	if(days > 0) {
+		const char *format;
+
+		format = dngettext(GETTEXT_PACKAGE, "%d day", "%d days", days);
+
+		ret = g_strdup_printf(format, days);
 	}
 
-	if (hrs > 0)
-	{
-		if (ret != NULL)
-		{
-			char *tmp = g_strdup_printf(
-					dngettext(PACKAGE, "%s, %d hour", "%s, %d hours", hrs),
-							ret, hrs);
+	if(hrs > 0) {
+		if(ret != NULL) {
+			char *tmp = NULL;
+			const char *format;
+
+			format = dngettext(GETTEXT_PACKAGE, "%s, %d hour", "%s, %d hours",
+			                   hrs);
+
+			tmp = g_strdup_printf(format, ret, hrs);
 			g_free(ret);
 			ret = tmp;
+		} else {
+			const char *format;
+
+			format = dngettext(GETTEXT_PACKAGE, "%d hour", "%d hours", hrs);
+
+			ret = g_strdup_printf(format, hrs);
 		}
-		else
-			ret = g_strdup_printf(dngettext(PACKAGE, "%d hour", "%d hours", hrs), hrs);
 	}
 
-	if (mins > 0)
-	{
-		if (ret != NULL)
-		{
-			char *tmp = g_strdup_printf(
-					dngettext(PACKAGE, "%s, %d minute", "%s, %d minutes", mins),
-							ret, mins);
+	if(mins > 0) {
+		if (ret != NULL) {
+			char *tmp;
+			const char *format;
+
+			format = dngettext(GETTEXT_PACKAGE, "%s, %d minute",
+			                   "%s, %d minutes", mins);
+			tmp = g_strdup_printf(format, ret, mins);
 			g_free(ret);
 			ret = tmp;
+		} else {
+			const char *format;
+
+			format = dngettext(GETTEXT_PACKAGE, "%d minute", "%d minutes",
+			                   mins);
+
+			ret = g_strdup_printf(format, mins);
 		}
-		else
-			ret = g_strdup_printf(dngettext(PACKAGE, "%d minute", "%d minutes", mins), mins);
 	}
 
 	return ret;
diff --git a/meson.build b/meson.build
--- a/meson.build
+++ b/meson.build
@@ -53,8 +53,6 @@
 version_conf = configuration_data()
 
 conf.set_quoted('GETTEXT_PACKAGE', GETTEXT_PACKAGE)
-conf.set_quoted('PACKAGE', meson.project_name())
-conf.set_quoted('PACKAGE_NAME', meson.project_name())
 conf.set_quoted('VERSION', meson.project_version())
 conf.set_quoted('DISPLAY_VERSION', meson.project_version())
 
diff --git a/pidgin/libpidgin.c b/pidgin/libpidgin.c
--- a/pidgin/libpidgin.c
+++ b/pidgin/libpidgin.c
@@ -36,9 +36,9 @@
 	GApplication *app;
 	int ret;
 
-	bindtextdomain(PACKAGE, PURPLE_LOCALEDIR);
-	bind_textdomain_codeset(PACKAGE, "UTF-8");
-	textdomain(PACKAGE);
+	bindtextdomain(GETTEXT_PACKAGE, purple_get_locale_dir());
+	bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8");
+	textdomain(GETTEXT_PACKAGE);
 
 	/* Locale initialization is not complete here.  See gtk_init_check() */
 	setlocale(LC_ALL, "");
diff --git a/pidgin/pidginabout.c b/pidgin/pidginabout.c
--- a/pidgin/pidginabout.c
+++ b/pidgin/pidginabout.c
@@ -440,6 +440,10 @@
 	/* add the data directory path */
 	pidgin_about_dialog_group_add_row(about->conf_path_info_group, _("Data"),
 	                                  purple_data_dir());
+
+	/* add the locale directory path */
+	pidgin_about_dialog_group_add_row(about->conf_path_info_group, _("Locale"),
+	                                  purple_get_locale_dir());
 }
 
 static char *
@@ -451,10 +455,12 @@
 		"===================\n"
 		"Cache: %s\n"
 		"Configuration: %s\n"
-		"Data: %s\n",
+		"Data: %s\n"
+		"Locale: %s\n",
 		purple_cache_dir(),
 		purple_config_dir(),
-		purple_data_dir());
+		purple_data_dir(),
+		purple_get_locale_dir());
 
 	return info;
 }
diff --git a/po/meson.build b/po/meson.build
--- a/po/meson.build
+++ b/po/meson.build
@@ -4,3 +4,5 @@
 # https://github.com/mesonbuild/meson/blob/master/mesonbuild/modules/i18n.py#L93
 # at the time of this comment.
 i18n.gettext(GETTEXT_PACKAGE, preset : 'glib')
+
+devenv.append('PURPLE_LOCALE_DIR', meson.current_build_dir())
