From 99b735cc03e51c330c623810af476c1647308b49 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <peter_e@gmx.net>
Date: Sat, 27 Nov 2004 22:44:15 +0000
Subject: [PATCH] Work around lack of NLS support in libpgport by making those
 components who use it scan the relevant source files for their own catalog. 
 It creates a bit of duplicate work for translators, but it gets the job done
 for now.

---
 src/backend/nls.mk       |  4 ++--
 src/bin/initdb/nls.mk    |  4 ++--
 src/bin/pg_config/nls.mk |  4 ++--
 src/bin/pg_ctl/nls.mk    |  4 ++--
 src/bin/pg_dump/nls.mk   |  5 +++--
 src/bin/psql/nls.mk      |  5 +++--
 src/port/dirmod.c        | 10 ++++------
 src/port/exec.c          | 22 ++++++++++------------
 8 files changed, 28 insertions(+), 30 deletions(-)

diff --git a/src/backend/nls.mk b/src/backend/nls.mk
index e053fe5084..42981290b9 100644
--- a/src/backend/nls.mk
+++ b/src/backend/nls.mk
@@ -1,4 +1,4 @@
-# $PostgreSQL: pgsql/src/backend/nls.mk,v 1.15 2004/08/11 09:00:27 petere Exp $
+# $PostgreSQL: pgsql/src/backend/nls.mk,v 1.16 2004/11/27 22:44:10 petere Exp $
 CATALOG_NAME	:= postgres
 AVAIL_LANGUAGES	:= af cs de es fr hr hu it nb pt_BR ru sk sv tr zh_CN zh_TW
 GETTEXT_FILES	:= + gettext-files
@@ -7,7 +7,7 @@ GETTEXT_FILES	:= + gettext-files
 GETTEXT_TRIGGERS:= errmsg errdetail errhint errcontext write_stderr yyerror
 
 gettext-files: distprep
-	find $(srcdir)/ -name '*.c' -print >$@
+	find $(srcdir)/ $(srcdir)/../port/ -name '*.c' -print >$@
 
 my-maintainer-clean:
 	rm -f gettext-files
diff --git a/src/bin/initdb/nls.mk b/src/bin/initdb/nls.mk
index acf1659c82..56bea55121 100644
--- a/src/bin/initdb/nls.mk
+++ b/src/bin/initdb/nls.mk
@@ -1,5 +1,5 @@
-# $PostgreSQL: pgsql/src/bin/initdb/nls.mk,v 1.15 2004/11/16 22:43:48 petere Exp $
+# $PostgreSQL: pgsql/src/bin/initdb/nls.mk,v 1.16 2004/11/27 22:44:11 petere Exp $
 CATALOG_NAME	:= initdb
 AVAIL_LANGUAGES	:= cs de es fr it pt_BR ro ru sk sl sv tr zh_CN zh_TW
-GETTEXT_FILES	:= initdb.c
+GETTEXT_FILES	:= initdb.c ../../port/dirmod.c ../../port/exec.c
 GETTEXT_TRIGGERS:= _ simple_prompt
diff --git a/src/bin/pg_config/nls.mk b/src/bin/pg_config/nls.mk
index 65c2852417..f60857622a 100644
--- a/src/bin/pg_config/nls.mk
+++ b/src/bin/pg_config/nls.mk
@@ -1,5 +1,5 @@
-# $PostgreSQL: pgsql/src/bin/pg_config/nls.mk,v 1.11 2004/11/23 23:13:07 petere Exp $
+# $PostgreSQL: pgsql/src/bin/pg_config/nls.mk,v 1.12 2004/11/27 22:44:12 petere Exp $
 CATALOG_NAME	:= pg_config
 AVAIL_LANGUAGES	:= cs de es fr pt_BR ro ru sl sv tr zh_TW
-GETTEXT_FILES	:= pg_config.c
+GETTEXT_FILES	:= pg_config.c ../../port/exec.c
 GETTEXT_TRIGGERS:= _
diff --git a/src/bin/pg_ctl/nls.mk b/src/bin/pg_ctl/nls.mk
index 23f7bba917..a915ffbd13 100644
--- a/src/bin/pg_ctl/nls.mk
+++ b/src/bin/pg_ctl/nls.mk
@@ -1,5 +1,5 @@
-# $PostgreSQL: pgsql/src/bin/pg_ctl/nls.mk,v 1.13 2004/11/23 23:13:18 petere Exp $
+# $PostgreSQL: pgsql/src/bin/pg_ctl/nls.mk,v 1.14 2004/11/27 22:44:13 petere Exp $
 CATALOG_NAME	:= pg_ctl
 AVAIL_LANGUAGES	:= cs de es fr pt_BR ro ru sk sl sv tr zh_CN zh_TW
-GETTEXT_FILES	:= pg_ctl.c
+GETTEXT_FILES	:= pg_ctl.c ../../port/exec.c
 GETTEXT_TRIGGERS:= _ simple_prompt
diff --git a/src/bin/pg_dump/nls.mk b/src/bin/pg_dump/nls.mk
index 945ba04527..54c1fcd626 100644
--- a/src/bin/pg_dump/nls.mk
+++ b/src/bin/pg_dump/nls.mk
@@ -1,8 +1,9 @@
-# $PostgreSQL: pgsql/src/bin/pg_dump/nls.mk,v 1.17 2004/11/18 10:09:58 petere Exp $
+# $PostgreSQL: pgsql/src/bin/pg_dump/nls.mk,v 1.18 2004/11/27 22:44:13 petere Exp $
 CATALOG_NAME	:= pg_dump
 AVAIL_LANGUAGES	:= cs de es fr it nb pt_BR ro ru sk sl sv tr zh_CN zh_TW
 GETTEXT_FILES	:= pg_dump.c common.c pg_backup_archiver.c pg_backup_custom.c \
                    pg_backup_db.c pg_backup_files.c pg_backup_null.c \
-                   pg_backup_tar.c pg_restore.c pg_dumpall.c
+                   pg_backup_tar.c pg_restore.c pg_dumpall.c \
+                   ../../port/exec.c
 GETTEXT_TRIGGERS:= write_msg:2 die_horribly:3 exit_horribly:3 simple_prompt \
                    ExecuteSqlCommand:3 ahlog:3 _
diff --git a/src/bin/psql/nls.mk b/src/bin/psql/nls.mk
index 9ca4a7e8d3..6e7f56d1b6 100644
--- a/src/bin/psql/nls.mk
+++ b/src/bin/psql/nls.mk
@@ -1,6 +1,7 @@
-# $PostgreSQL: pgsql/src/bin/psql/nls.mk,v 1.19 2004/11/07 23:38:15 petere Exp $
+# $PostgreSQL: pgsql/src/bin/psql/nls.mk,v 1.20 2004/11/27 22:44:14 petere Exp $
 CATALOG_NAME	:= psql
 AVAIL_LANGUAGES	:= cs de es fa fr hu it nb pt_BR ro ru sk sl sv tr zh_CN zh_TW
 GETTEXT_FILES	:= command.c common.c copy.c help.c input.c large_obj.c \
-                   mainloop.c print.c startup.c describe.c sql_help.h
+                   mainloop.c print.c startup.c describe.c sql_help.h \
+                   ../../port/exec.c
 GETTEXT_TRIGGERS:= _ N_ psql_error simple_prompt
diff --git a/src/port/dirmod.c b/src/port/dirmod.c
index 0443b600e1..445fd95fa1 100644
--- a/src/port/dirmod.c
+++ b/src/port/dirmod.c
@@ -10,7 +10,7 @@
  *	Win32 (NT, Win2k, XP).	replace() doesn't work on Win95/98/Me.
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/port/dirmod.c,v 1.32 2004/10/28 22:09:31 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/port/dirmod.c,v 1.33 2004/11/27 22:44:15 petere Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -40,8 +40,6 @@
 #endif
 #endif
 
-#define _(x) gettext((x))
-
 #ifndef FRONTEND
 
 /*
@@ -74,7 +72,7 @@ fe_palloc(Size size)
 
 	if ((res = malloc(size)) == NULL)
 	{
-		fprintf(stderr, _("out of memory\n"));
+		fprintf(stderr, gettext("out of memory\n"));
 		exit(1);
 	}
 	return res;
@@ -87,7 +85,7 @@ fe_pstrdup(const char *string)
 
 	if ((res = strdup(string)) == NULL)
 	{
-		fprintf(stderr, _("out of memory\n"));
+		fprintf(stderr, gettext("out of memory\n"));
 		exit(1);
 	}
 	return res;
@@ -100,7 +98,7 @@ fe_repalloc(void *pointer, Size size)
 
 	if ((res = realloc(pointer, size)) == NULL)
 	{
-		fprintf(stderr, _("out of memory\n"));
+		fprintf(stderr, gettext("out of memory\n"));
 		exit(1);
 	}
 	return res;
diff --git a/src/port/exec.c b/src/port/exec.c
index 28b25c4b7f..19ab92a072 100644
--- a/src/port/exec.c
+++ b/src/port/exec.c
@@ -9,7 +9,7 @@
  *
  *
  * IDENTIFICATION
- *	  $PostgreSQL: pgsql/src/port/exec.c,v 1.32 2004/11/06 23:06:29 tgl Exp $
+ *	  $PostgreSQL: pgsql/src/port/exec.c,v 1.33 2004/11/27 22:44:15 petere Exp $
  *
  *-------------------------------------------------------------------------
  */
@@ -28,8 +28,6 @@
 #include <unistd.h>
 #endif
 
-#define _(x) gettext(x)
-
 #ifndef S_IRUSR					/* XXX [TRH] should be in a header */
 #define S_IRUSR		 S_IREAD
 #define S_IWUSR		 S_IWRITE
@@ -192,7 +190,7 @@ find_my_exec(const char *argv0, char *retpath)
 
 	if (!getcwd(cwd, MAXPGPATH))
 	{
-		log_error(_("could not identify current directory: %s"),
+		log_error(gettext("could not identify current directory: %s"),
 				  strerror(errno));
 		return -1;
 	}
@@ -306,7 +304,7 @@ resolve_symlinks(char *path)
 	 */
 	if (!getcwd(orig_wd, MAXPGPATH))
 	{
-		log_error(_("could not identify current directory: %s"),
+		log_error(gettext("could not identify current directory: %s"),
 				  strerror(errno));
 		return -1;
 	}
@@ -322,7 +320,7 @@ resolve_symlinks(char *path)
 			*lsep = '\0';
 			if (chdir(path) == -1)
 			{
-				log_error(_("could not change directory to \"%s\""), path);
+				log_error(gettext("could not change directory to \"%s\""), path);
 				return -1;
 			}
 			fname = lsep + 1;
@@ -337,7 +335,7 @@ resolve_symlinks(char *path)
 		rllen = readlink(fname, link_buf, sizeof(link_buf));
 		if (rllen < 0 || rllen >= sizeof(link_buf))
 		{
-			log_error(_("could not read symbolic link \"%s\""), fname);
+			log_error(gettext("could not read symbolic link \"%s\""), fname);
 			return -1;
 		}
 		link_buf[rllen] = '\0';
@@ -349,7 +347,7 @@ resolve_symlinks(char *path)
 
 	if (!getcwd(path, MAXPGPATH))
 	{
-		log_error(_("could not identify current directory: %s"),
+		log_error(gettext("could not identify current directory: %s"),
 				  strerror(errno));
 		return -1;
 	}
@@ -358,7 +356,7 @@ resolve_symlinks(char *path)
 
 	if (chdir(orig_wd) == -1)
 	{
-		log_error(_("could not change directory to \"%s\""), orig_wd);
+		log_error(gettext("could not change directory to \"%s\""), orig_wd);
 		return -1;
 	}
 
@@ -568,13 +566,13 @@ pclose_check(FILE *stream)
 		perror("pclose failed");
 	}
 	else if (WIFEXITED(exitstatus))
-		log_error(_("child process exited with exit code %d"),
+		log_error(gettext("child process exited with exit code %d"),
 				  WEXITSTATUS(exitstatus));
 	else if (WIFSIGNALED(exitstatus))
-		log_error(_("child process was terminated by signal %d"),
+		log_error(gettext("child process was terminated by signal %d"),
 				  WTERMSIG(exitstatus));
 	else
-		log_error(_("child process exited with unrecognized status %d"),
+		log_error(gettext("child process exited with unrecognized status %d"),
 				  exitstatus);
 
 	return -1;
-- 
2.24.1