aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorArnold D. Robbins <arnold@skeeve.com>2016-07-18 05:35:19 +0300
committerArnold D. Robbins <arnold@skeeve.com>2016-07-18 05:35:19 +0300
commitf3c40366f29a270cb659cedf241b708fcfedb679 (patch)
tree406d9ffd328428c2f62a0af7a9997e3d64bf1236
parent87e61996806174f405b0aab9c92688945b9dca77 (diff)
downloadegawk-f3c40366f29a270cb659cedf241b708fcfedb679.tar.gz
egawk-f3c40366f29a270cb659cedf241b708fcfedb679.tar.bz2
egawk-f3c40366f29a270cb659cedf241b708fcfedb679.zip
Reenable translation during arg parsing.
-rw-r--r--ChangeLog12
-rw-r--r--NEWS8
-rw-r--r--doc/ChangeLog5
-rw-r--r--doc/gawktexi.in25
-rw-r--r--main.c23
5 files changed, 70 insertions, 3 deletions
diff --git a/ChangeLog b/ChangeLog
index 0cd422ac..c341c683 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
2016-07-17 Arnold D. Robbins <arnold@skeeve.com>
+ * main.c (locale_dir): New variable, init to LOCALEDIR (set by
+ configure).
+ (set_locale_stuff): Move calls to bindtextdomain and
+ textdomain to here; they must be done after calling setlocale.
+ Use locale_dir instead of LOCALEDIR.
+ (main): Move call to set_locale_stuff() to before parsing arguments.
+ Check for GAWK_LOCALE_DIR env var and use it if there. If doing
+ locale debugging, call set_locale_stuff again if arg parsing changed
+ the locale.
+
+2016-07-17 Arnold D. Robbins <arnold@skeeve.com>
+
* eval.c (set_LINT): Reset lintfunc to `warning' for LINT="invalid".
Thanks to Andy Schorr for the report.
diff --git a/NEWS b/NEWS
index 8474e69a..ca891f8b 100644
--- a/NEWS
+++ b/NEWS
@@ -38,6 +38,14 @@ Changes from 4.1.3 to 4.1.4
11. The -d option now allows -d- to print to standard output.
+12. Error messages for --help and in other instances should now get
+ translated correctly.
+
+13. A new environment variable GAWK_LOCALE_DIR may be set to locate the .mo
+ file for gawk itself.
+
+14. A number of bugs have been fixed. See the ChangeLog.
+
Changes from 4.1.2 to 4.1.3
---------------------------
diff --git a/doc/ChangeLog b/doc/ChangeLog
index 24929efc..d06f5632 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2016-07-17 Arnold D. Robbins <arnold@skeeve.com>
+
+ * gawktexi.in: Document GAWK_LOCALE_DIR env var and also to not
+ use LANGUAGE env var.
+
2016-07-12 Arnold D. Robbins <arnold@skeeve.com>
* gawktexi.in (Auto-set): Add example use of multiply function.
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 6bf97aec..002936c8 100644
--- a/doc/gawktexi.in
+++ b/doc/gawktexi.in
@@ -4477,6 +4477,11 @@ are generated. Its purpose is to help isolate the source of a
message, as there are multiple places that produce the
same warning or error message.
+@item GAWK_LOCALE_DIR
+Specifies the location of compiled message object files
+for @command{gawk} itself. This is passed to the @code{bindtextdomain()}
+function when @command{gawk} starts up.
+
@item GAWK_NO_DFA
If this variable exists, @command{gawk} does not use the DFA regexp matcher
for ``does it match'' kinds of tests. This can cause @command{gawk}
@@ -27400,6 +27405,26 @@ before or after the day in a date, local month abbreviations, and so on.
All of the above. (Not too useful in the context of @command{gettext}.)
@end table
+@quotation NOTE
+@cindex @env{LANGUAGE} environment variable
+As described in @ref{Locales}, environment variables with the same
+name as the locale categories (@env{LC_CTYPE}, @env{LC_ALL}, etc.)
+influence @command{gawk}'s behavior (and that of other utilities).
+
+Normally, these variables also affect how the @code{gettext} library
+finds translations. However, the @env{LANGUAGE} environment variable
+overrides the @env{LC_@var{xxx}} variables. Many GNU/Linux systems
+may define this variable without your knowledge, causing @command{gawk}
+to not find the correct translations. If this happens to you,
+look to see if @env{LANGAUGE} is defined, and if so, use the shell's
+@command{unset} command to remove it.
+@end quotation
+
+For testing translations of @command{gawk} itself, you can set
+the @env{GAWK_LOCALE_DIR} environment variable. See the documentation
+for the C @code{bindtextdomain()} function and also see
+@ref{Other Environment Variables}.
+
@node Programmer i18n
@section Internationalizing @command{awk} Programs
@cindex @command{awk} programs, internationalizing
diff --git a/main.c b/main.c
index 82b86a8a..be210036 100644
--- a/main.c
+++ b/main.c
@@ -152,6 +152,7 @@ static int do_nostalgia = false; /* provide a blast from the past */
static int do_binary = false; /* hands off my data! */
static int do_version = false; /* print version info */
static const char *locale = ""; /* default value to setlocale */
+static char *locale_dir = LOCALEDIR; /* default locale dir */
int use_lc_numeric = false; /* obey locale for decimal point */
@@ -219,6 +220,10 @@ main(int argc, char **argv)
char *extra_stack;
int have_srcfile = 0;
SRCFILE *s;
+ char *cp;
+#if defined(LOCALEDEBUG)
+ const char *initial_locale;
+#endif
/* do these checks early */
if (getenv("TIDYMEM") != NULL)
@@ -237,8 +242,13 @@ main(int argc, char **argv)
if (argc < 2)
usage(EXIT_FAILURE, stderr);
- (void) bindtextdomain(PACKAGE, LOCALEDIR);
- (void) textdomain(PACKAGE);
+ if ((cp = getenv("GAWK_LOCALE_DIR")) != NULL)
+ locale_dir = cp;
+
+#if defined(LOCALEDEBUG)
+ initial_locale = locale;
+#endif
+ set_locale_stuff();
(void) signal(SIGFPE, catchsig);
#ifdef SIGBUS
@@ -286,7 +296,10 @@ main(int argc, char **argv)
parse_args(argc, argv);
- set_locale_stuff();
+#if defined(LOCALEDEBUG)
+ if (locale != initial_locale)
+ set_locale_stuff();
+#endif
/*
* In glibc, MB_CUR_MAX is actually a function. This value is
@@ -1683,4 +1696,8 @@ set_locale_stuff(void)
#if defined(LC_TIME)
setlocale(LC_TIME, locale);
#endif
+
+ /* These must be done after calling setlocale */
+ (void) bindtextdomain(PACKAGE, locale_dir);
+ (void) textdomain(PACKAGE);
}