bug-gawk
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [bug-gawk] --help isn't l10n


From: Aharon Robbins
Subject: Re: [bug-gawk] --help isn't l10n
Date: Mon, 18 Jul 2016 05:45:07 +0300
User-agent: Heirloom mailx 12.5 6/20/10

Greetings. Re this:

> To: address@hidden
> From: Tr???n Ng???c Qu??n <address@hidden>
> Date: Fri, 8 Jul 2016 07:43:48 +0700
> Subject: [bug-gawk] --help isn't l10n
>
> Hi,
>
> --help don't display l10n string, but when use with a wrong option, (
> ex. --wrong) help string is l10n, and it not say that it is a wrong option.
>
> I'm using gawk 4.1.3h
>
> Thanks,
> -- 
> Tr???n Ng???c Qu??n.

This was an interesting one to track down. Here is the fix. I will
push it shortly.

Thanks,

Arnold
----------------------------------------
diff --git a/ChangeLog b/ChangeLog
index 0cd422a..c341c68 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,17 @@
 2016-07-17         Arnold D. Robbins     <address@hidden>
 
+       * 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     <address@hidden>
+
        * 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 8474e69..3e9c012 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 24929ef..d06f563 100644
--- a/doc/ChangeLog
+++ b/doc/ChangeLog
@@ -1,3 +1,8 @@
+2016-07-17         Arnold D. Robbins     <address@hidden>
+
+       * gawktexi.in: Document GAWK_LOCALE_DIR env var and also to not
+       use LANGUAGE env var.
+
 2016-07-12         Arnold D. Robbins     <address@hidden>
 
        * gawktexi.in (Auto-set): Add example use of multiply function.
diff --git a/doc/gawktexi.in b/doc/gawktexi.in
index 6bf97ae..002936c 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.
 
address@hidden 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
 
address@hidden NOTE
address@hidden @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 @address@hidden 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
address@hidden command to remove it.
address@hidden 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
address@hidden Environment Variables}.
+
 @node Programmer i18n
 @section Internationalizing @command{awk} Programs
 @cindex @command{awk} programs, internationalizing
diff --git a/main.c b/main.c
index 82b86a8..be21003 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);
 }



reply via email to

[Prev in Thread] Current Thread [Next in Thread]