From: Paul Eggert Date: Tue, 12 Jul 2005 23:28:54 +0000 (+0000) Subject: * bootstrap: Get runtime translations into runtime-po. X-Git-Tag: BISON-2_1~99 X-Git-Url: https://git.saurik.com/bison.git/commitdiff_plain/f7ab6a5010b6cac6eaa6b6d9e54168764bffed7a * bootstrap: Get runtime translations into runtime-po. Create runtime-po files automatically, if possible. * configure.ac: Invoke BISON_I18N, so that we eat our own dog food. * data/yacc.c: Rewrite inclusion of so that ENABLE_NLS does not infringe on the user's name space. (YYENABLE_NLS): Renamed from ENABLE_BISON_NLS. * doc/bison.texinfo (Internationalization): Revamp the English and Texinfo syntax a bit, to try to make it clearer. (Bison Options, Option Cross Key): Mention --print-localedir. * m4/bison-i18n.m4 (BISON_I18N): Rename ENABLE_BISON_NLS to YYENABLE_NLS. Quote a bit more. * runtime-po/.cvsignore: New file. * runtime-po/Makefile.in.in (mostlyclean): Remove *.old.pot. * runtime-po/Rules-quot: Remove; now created by bootstrap. * runtime-po/quot.sed: Likewise. * runtime-po/boldquot.sed: Likewise. * runtime-po/en@quot.header: Likewise. * runtime-po/en@boldquot.header: Likewise. * runtime-po/insert-header.sin: Likewise. * runtime-po/remove-potcdate.sin: Likewise. * runtime-po/Makevars: Likewise. * runtime-po/LINGUAS: Likewise. * runtime-po/de.po: Likewise; we will rely on the translation project to maintain this, so "bootstrap" should get it. * src/getarg.s (PRINT_LOCALEDIR_OPTION): Let the C compiler determine its value. * src/main.c (main): Bind the bison-runtime domain, too. * data/yacc.c: Include when NLS is enabled. (YYI18N): Renamed from _. Use dgettext when NLS is enabled. * po/POTFILES.in: Remove autogenerated file src/parse-gram.c. * runtime-po: New directory. * runtime-po/Makefile.in.in: New file, copied from po/, with modified $(DOMAIN).pot-update rule, so that old messages are never dropped. * runtime-po/Rules-quot: New file, copied from po/. * runtime-po/quot.sed: Likewise. * runtime-po/boldquot.sed: Likewise. * runtime-po/en@quot.header: Likewise. * runtime-po/en@boldquot.header: Likewise. * runtime-po/insert-header.sin: Likewise. * runtime-po/remove-potcdate.sin: Likewise. * runtime-po/Makevars: New file. * runtime-po/POTFILES.in: New file. * runtime-po/LINGUAS: New file. * runtime-po/bison-runtime.pot: New file. * runtime-po/de.po: New file. * m4/bison.m4: New file. * Makefile.am (SUBDIRS): Add runtime-po. (aclocaldir, aclocal_DATA): New variables. * configure.ac: Add AC_CONFIG_FILES of runtime-po/Makefile.in. Define aclocaldir. * src/getargs.c (usage): Document --print-localedir option. (PRINT_LOCALEDIR_OPTION): New enum item. (long_options): Add --print-localedir option. (getargs): Handle --print-localedir option. * doc/bison.texinfo (Bison Parser): Remove paragraph about _(). (Internationalization): New section. --- diff --git a/ChangeLog b/ChangeLog index c5885f4b..53e6ea56 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,65 @@ +2005-07-12 Paul Eggert + + * bootstrap: Get runtime translations into runtime-po. + Create runtime-po files automatically, if possible. + * configure.ac: Invoke BISON_I18N, so that we eat our own dog food. + * data/yacc.c: Rewrite inclusion of so that ENABLE_NLS + does not infringe on the user's name space. + (YYENABLE_NLS): Renamed from ENABLE_BISON_NLS. + * doc/bison.texinfo (Internationalization): Revamp the English + and Texinfo syntax a bit, to try to make it clearer. + (Bison Options, Option Cross Key): Mention --print-localedir. + * m4/bison-i18n.m4 (BISON_I18N): Rename ENABLE_BISON_NLS to + YYENABLE_NLS. Quote a bit more. + * runtime-po/.cvsignore: New file. + * runtime-po/Makefile.in.in (mostlyclean): Remove *.old.pot. + * runtime-po/Rules-quot: Remove; now created by bootstrap. + * runtime-po/quot.sed: Likewise. + * runtime-po/boldquot.sed: Likewise. + * runtime-po/en@quot.header: Likewise. + * runtime-po/en@boldquot.header: Likewise. + * runtime-po/insert-header.sin: Likewise. + * runtime-po/remove-potcdate.sin: Likewise. + * runtime-po/Makevars: Likewise. + * runtime-po/LINGUAS: Likewise. + * runtime-po/de.po: Likewise; we will rely on the translation project + to maintain this, so "bootstrap" should get it. + * src/getarg.s (PRINT_LOCALEDIR_OPTION): Let the C compiler determine + its value. + * src/main.c (main): Bind the bison-runtime domain, too. + +2005-07-12 Bruno Haible + + * data/yacc.c: Include when NLS is enabled. + (YYI18N): Renamed from _. Use dgettext when NLS is enabled. + * po/POTFILES.in: Remove autogenerated file src/parse-gram.c. + * runtime-po: New directory. + * runtime-po/Makefile.in.in: New file, copied from po/, with modified + $(DOMAIN).pot-update rule, so that old messages are never dropped. + * runtime-po/Rules-quot: New file, copied from po/. + * runtime-po/quot.sed: Likewise. + * runtime-po/boldquot.sed: Likewise. + * runtime-po/en@quot.header: Likewise. + * runtime-po/en@boldquot.header: Likewise. + * runtime-po/insert-header.sin: Likewise. + * runtime-po/remove-potcdate.sin: Likewise. + * runtime-po/Makevars: New file. + * runtime-po/POTFILES.in: New file. + * runtime-po/LINGUAS: New file. + * runtime-po/bison-runtime.pot: New file. + * runtime-po/de.po: New file. + * m4/bison.m4: New file. + * Makefile.am (SUBDIRS): Add runtime-po. + (aclocaldir, aclocal_DATA): New variables. + * configure.ac: Add AC_CONFIG_FILES of runtime-po/Makefile.in. + Define aclocaldir. + * src/getargs.c (usage): Document --print-localedir option. + (PRINT_LOCALEDIR_OPTION): New enum item. + (long_options): Add --print-localedir option. + (getargs): Handle --print-localedir option. + * doc/bison.texinfo (Bison Parser): Remove paragraph about _(). + (Internationalization): New section. + 2005-07-12 Akim Demaille * src/symtab.h, src/symtab.c (symbol_print): Swap the arguments, diff --git a/Makefile.am b/Makefile.am index 3baff6fb..b463a05d 100644 --- a/Makefile.am +++ b/Makefile.am @@ -18,7 +18,11 @@ ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = config po lib data src doc tests examples +SUBDIRS = config po runtime-po lib data src doc tests + +# Files installed for use by Automake. +aclocaldir = @aclocaldir@ +aclocal_DATA = m4/bison-i18n.m4 EXTRA_DIST = REFERENCES OChangeLog Makefile.maint GNUmakefile Makefile.cfg diff --git a/bootstrap b/bootstrap index 658beaa9..1207d6b0 100755 --- a/bootstrap +++ b/bootstrap @@ -170,7 +170,18 @@ case $SKIP_PO in wget -nv -nd -r -l 1 -A .po -C off \ http://www.iro.umontreal.ca/translation/maint/$package/ && ls *.po | sed 's/\.po$//' >LINGUAS - ) || exit;; + ) || exit + + case $package in + bison) + echo "$0: getting translations into po (please ignore the robots.txt ERROR 404)..." + (cd runtime-po && + rm -f dummy `ls | sed -n '/\.gmo$/p; /\.po$/p'` && + wget -nv -nd -r -l 1 -A .po -C off \ + http://www.iro.umontreal.ca/translation/maint/$package-runtime/ && + ls *.po | sed 's/\.po$//' >LINGUAS + ) || exit + esac;; esac @@ -231,6 +242,15 @@ rm -fr $intl_files_to_remove || exit echo "$0: sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-bison@gnu.org/' po/Makevars.template >po/Makevars ..." sed '/^MSGID_BUGS_ADDRESS *=/s/=.*/= bug-bison@gnu.org/' po/Makevars.template >po/Makevars +# Likewise for runtime-po/Makevars, except also change a few other parameters. +sed ' + s/^\(DOMAIN\) *=.*/\1 = bison-runtime/ + s/^\(subdir\) *=.*/\1 = runtime-po/ + s/^\(XGETTEXT_OPTIONS\) *=.*/\1 = --keyword=YYI18N/ +' runtime-po/Makevars + +# Copy identical files from po to runtime-po. +(cd po && cp -p *-quot *.header *.sed *.sin ../runtime-po) # if src/parse-gram.[ch] are out of date, rebuild them. parse_gram_y=`find src/parse-gram.y \ diff --git a/configure.ac b/configure.ac index fb1a97c9..1bf79a08 100644 --- a/configure.ac +++ b/configure.ac @@ -107,8 +107,15 @@ BISON_PREREQ_TIMEVAR # gnulib and gettext. GNULIB_AUTOCONF_SNIPPET -# We use po/Makevars.template, so we need at least gettext 0.12. +# We use po/Makevars, so we need at least gettext 0.12. AM_GNU_GETTEXT_VERSION([0.12]) +BISON_I18N + +# Internationalized parsers. +AC_CONFIG_FILES([runtime-po/Makefile.in]) +# Autoconf macros for packages using internationalized parsers. +aclocaldir='${datadir}/aclocal' +AC_SUBST([aclocaldir]) # Initialize the test suite. AC_CONFIG_TESTDIR(tests) diff --git a/data/yacc.c b/data/yacc.c index 945d0960..74868413 100644 --- a/data/yacc.c +++ b/data/yacc.c @@ -412,9 +412,16 @@ static const char *const yytname[] = }; #endif -/* INFRINGES ON USER NAME SPACE */ -#ifndef _ -# define _(msgid) msgid +#ifndef YYI18N +# if YYENABLE_NLS +# if ENABLE_NLS +# include /* INFRINGES ON USER NAME SPACE */ +# define YYI18N(msgid) dgettext ("bison-runtime", msgid) +# endif +# endif +# ifndef YYI18N +# define YYI18N(msgid) msgid +# endif #endif # ifdef YYPRINT @@ -518,7 +525,7 @@ do \ } \ else \ { \ - yyerror (]b4_yyerror_args[_("syntax error: cannot back up")); \ + yyerror (]b4_yyerror_args[YYI18N ("syntax error: cannot back up")); \ YYERROR; \ } \ while (0) @@ -612,7 +619,7 @@ do { \ [[short int *bottom], [bottom]], [[short int *top], [top]])[ { - YYFPRINTF (stderr, _("Stack now")); + YYFPRINTF (stderr, YYI18N ("Stack now")); for (/* Nothing. */; bottom <= top; ++bottom) YYFPRINTF (stderr, " %d", *bottom); YYFPRINTF (stderr, "\n"); @@ -634,7 +641,7 @@ do { \ { int yyi; unsigned int yylno = yyrline[yyrule]; - YYFPRINTF (stderr, _("Reducing stack by rule %d (line %u), "), + YYFPRINTF (stderr, YYI18N ("Reducing stack by rule %d (line %u), "), yyrule - 1, yylno); /* Print the symbols being reduced, and their result. */ for (yyi = yyprhs[yyrule]; 0 <= yyrhs[yyi]; yyi++) @@ -904,7 +911,7 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; data in use in that stack, in bytes. This used to be a conditional around just the two extra args, but that might be undefined if yyoverflow is a macro. */ - yyoverflow (_("parser stack overflow"), + yyoverflow (YYI18N ("parser stack overflow"), &yyss1, yysize * sizeof (*yyssp), &yyvs1, yysize * sizeof (*yyvsp), ]b4_location_if([ &yyls1, yysize * sizeof (*yylsp),])[ @@ -944,14 +951,14 @@ m4_ifdef([b4_at_dollar_used], [[ yylsp[0] = yylloc; yyvsp = yyvs + yysize - 1; ]b4_location_if([ yylsp = yyls + yysize - 1;])[ - YYDPRINTF ((stderr, _("Stack size increased to %lu\n"), + YYDPRINTF ((stderr, YYI18N ("Stack size increased to %lu\n"), (unsigned long int) yystacksize)); if (yyss + yystacksize - 1 <= yyssp) YYABORT; } - YYDPRINTF ((stderr, _("Entering state %d\n"), yystate)); + YYDPRINTF ((stderr, YYI18N ("Entering state %d\n"), yystate)); goto yybackup; @@ -975,19 +982,19 @@ yybackup: /* YYCHAR is either YYEMPTY or YYEOF or a valid look-ahead symbol. */ if (yychar == YYEMPTY) { - YYDPRINTF ((stderr, _("Reading a token: "))); + YYDPRINTF ((stderr, YYI18N ("Reading a token: "))); yychar = YYLEX; } if (yychar <= YYEOF) { yychar = yytoken = YYEOF; - YYDPRINTF ((stderr, _("Now at end of input.\n"))); + YYDPRINTF ((stderr, YYI18N ("Now at end of input.\n"))); } else { yytoken = YYTRANSLATE (yychar); - YY_SYMBOL_PRINT (_("Next token is"), yytoken, &yylval, &yylloc); + YY_SYMBOL_PRINT (YYI18N ("Next token is"), yytoken, &yylval, &yylloc); } /* If the proper action on seeing token YYTOKEN is to reduce or to @@ -1008,7 +1015,7 @@ yybackup: YYACCEPT; /* Shift the look-ahead token. */ - YY_SYMBOL_PRINT (_("Shifting"), yytoken, &yylval, &yylloc); + YY_SYMBOL_PRINT (YYI18N ("Shifting"), yytoken, &yylval, &yylloc); /* Discard the token being shifted unless it is eof. */ if (yychar != YYEOF) @@ -1116,11 +1123,11 @@ yyerrlab: #if 0 /* This is so xgettext sees the translatable formats that are constructed on the fly. */ - _("syntax error, unexpected %s"); - _("syntax error, unexpected %s, expecting %s"); - _("syntax error, unexpected %s, expecting %s or %s"); - _("syntax error, unexpected %s, expecting %s or %s or %s"); - _("syntax error, unexpected %s, expecting %s or %s or %s or %s"); + YYI18N ("syntax error, unexpected %s"); + YYI18N ("syntax error, unexpected %s, expecting %s"); + YYI18N ("syntax error, unexpected %s, expecting %s or %s"); + YYI18N ("syntax error, unexpected %s, expecting %s or %s or %s"); + YYI18N ("syntax error, unexpected %s, expecting %s or %s or %s or %s"); #endif char *yyfmt; char const *yyf; @@ -1163,7 +1170,7 @@ yyerrlab: yyprefix = yyor; } - yyf = _(yyformat); + yyf = YYI18N (yyformat); yysize1 = yysize + yystrlen (yyf); yysize_overflow |= yysize1 < yysize; yysize = yysize1; @@ -1194,11 +1201,11 @@ yyerrlab: YYSTACK_FREE (yymsg); } else - yyerror (]b4_yyerror_args[_("syntax error; also memory exhausted")); + yyerror (]b4_yyerror_args[YYI18N ("syntax error; also memory exhausted")); } else #endif /* YYERROR_VERBOSE */ - yyerror (]b4_yyerror_args[_("syntax error")); + yyerror (]b4_yyerror_args[YYI18N ("syntax error")); } ]b4_location_if([[ yyerror_range[0] = yylloc;]])[ @@ -1217,7 +1224,7 @@ yyerrlab: } else { - yydestruct (_("Error: discarding"), yytoken, &yylval]b4_location_if([, &yylloc])[); + yydestruct (YYI18N ("Error: discarding"), yytoken, &yylval]b4_location_if([, &yylloc])[); yychar = YYEMPTY; } } @@ -1271,7 +1278,7 @@ yyerrlab1: YYABORT; ]b4_location_if([[ yyerror_range[0] = *yylsp;]])[ - yydestruct (_("Error: popping"), yystos[yystate], yyvsp]b4_location_if([, yylsp])[); + yydestruct (YYI18N ("Error: popping"), yystos[yystate], yyvsp]b4_location_if([, yylsp])[); YYPOPSTACK; yystate = *yyssp; YY_STACK_PRINT (yyss, yyssp); @@ -1289,7 +1296,7 @@ yyerrlab1: *++yylsp = yyloc;]])[ /* Shift the error token. */ - YY_SYMBOL_PRINT (_("Shifting"), yystos[yyn], yyvsp, yylsp); + YY_SYMBOL_PRINT (YYI18N ("Shifting"), yystos[yyn], yyvsp, yylsp); yystate = yyn; goto yynewstate; @@ -1314,14 +1321,14 @@ yyabortlab: | yyoverflowlab -- parser overflow comes here. | `----------------------------------------------*/ yyoverflowlab: - yyerror (]b4_yyerror_args[_("parser stack overflow")); + yyerror (]b4_yyerror_args[YYI18N ("parser stack overflow")); yyresult = 2; /* Fall through. */ #endif yyreturn: if (yychar != YYEOF && yychar != YYEMPTY) - yydestruct (_("Error: discarding lookahead"), + yydestruct (YYI18N ("Error: discarding lookahead"), yytoken, &yylval]b4_location_if([, &yylloc])[); if (yyssp != yyss) for (;;) @@ -1330,7 +1337,7 @@ yyreturn: YYPOPSTACK; if (yyssp == yyss) break; - yydestruct (_("Error: popping"), + yydestruct (YYI18N ("Error: popping"), yystos[*yyssp], yyvsp]b4_location_if([, yylsp])[); } #ifndef yyoverflow diff --git a/doc/bison.texinfo b/doc/bison.texinfo index 60226343..a8c60bc4 100644 --- a/doc/bison.texinfo +++ b/doc/bison.texinfo @@ -243,6 +243,8 @@ Parser C-Language Interface which reads tokens. * Error Reporting:: You must supply a function @code{yyerror}. * Action Features:: Special features for use in actions. +* Internationalization:: How to let the parser speak in the user's + native language. The Lexical Analyzer Function @code{yylex} @@ -1187,14 +1189,7 @@ start with a function called @code{main}; you have to provide this, and arrange for it to call @code{yyparse} or the parser will never run. @xref{Interface, ,Parser C-Language Interface}. -If your code defines a C preprocessor macro @code{_} (a single -underscore), Bison assumes that it can be used to translate -English-language strings to the user's preferred language using a -function-like syntax, e.g., @code{_("syntax error")}. Otherwise, -Bison defines a no-op macro by that name that merely returns its -argument, so strings are not translated. - -Aside from @code{_} and the token type names and the symbols in the actions you +Aside from the token type names and the symbols in the actions you write, all symbols defined in the Bison parser file itself begin with @samp{yy} or @samp{YY}. This includes interface functions such as the lexical analyzer function @code{yylex}, the error reporting @@ -4250,6 +4245,8 @@ in the grammar file, you are likely to run into trouble. which reads tokens. * Error Reporting:: You must supply a function @code{yyerror}. * Action Features:: Special features for use in actions. +* Internationalization:: How to let the parser speak in the user's + native language. @end menu @node Parser Function @@ -4812,6 +4809,84 @@ of the @var{n}th component of the current rule. @xref{Locations, , Tracking Locations}. @end deffn +@node Internationalization +@section Parser Internationalization +@cindex internationalization +@cindex i18n +@cindex NLS +@cindex gettext +@cindex bison-po + +A Bison-generated parser can print diagnostics, including error and +tracing messages. By default, they appear in English. However, Bison +also supports outputting diagnostics in the user's native language. +To make this work, the user should set the usual environment +variables. @xref{Using gettextized software, , User influence on +@code{gettext}, libc, The GNU C Library Reference Manual}. For +example, the shell command @samp{export LC_ALL=fr_CA.UTF-8} might set +the user's locale to French Canadian using the @acronym{UTF}-8 +encoding. The exact set of available locales depends on the user's +installation. + +The maintainer of a package that uses a Bison-generated parser enables +the internationalization of the parser's output through the following +steps. Here we assume a package that uses @acronym{GNU} Autoconf and +@acronym{GNU} Automake. + +@enumerate +@item +Into the directory containing the @acronym{GNU} Autoconf macros used +by the package---often called @file{m4}---copy the +@file{bison-i18n.m4} file installed by Bison under +@samp{share/aclocal/bison-i18n.m4} in Bison's installation directory. +For example: + +@example +cp /usr/local/share/aclocal/bison-i18n.m4 m4/bison-i18n.m4 +@end example + +@item +In the top-level @file{configure.ac}, after the @code{AM_GNU_GETTEXT} +invocation, add an invocation of @code{BISON_I18N}. This macro is +defined in the file @file{bison-i18n.m4} that you copied earlier. It +causes @samp{configure} to find the value of the +@code{BISON_LOCALEDIR} variable. + +@item +In the @code{main} function of your program, designate the directory +containing Bison's runtime message catalog, through a call to +@samp{bindtextdomain} with domain name @samp{bison-runtime}. +For example: + +@example +bindtextdomain ("bison-runtime", BISON_LOCALEDIR); +@end example + +Typically this appears after any other call @code{bindtextdomain +(PACKAGE, LOCALEDIR)} that your package already has. Here we rely on +@samp{BISON_LOCALEDIR} to be defined as a string through the +@file{Makefile}. + +@item +In the @file{Makefile.am} that controls the compilation of the @code{main} +function, make @samp{BISON_LOCALEDIR} available as a C preprocessor macro, +either in @samp{DEFS} or in @samp{AM_CPPFLAGS}. For example: + +@example +DEFS = @@DEFS@@ -DBISON_LOCALEDIR='"$(BISON_LOCALEDIR)"' +@end example + +or: + +@example +AM_CPPFLAGS = -DBISON_LOCALEDIR='"$(BISON_LOCALEDIR)"' +@end example + +@item +Finally, invoke the command @command{autoreconf} to generate the build +infrastructure. +@end enumerate + @node Algorithm @chapter The Bison Parser Algorithm @@ -6575,6 +6650,9 @@ Print a summary of the command-line options to Bison and exit. @itemx --version Print the version number of Bison and exit. +@item --print-localedir +Print the name of the directory containing locale-dependent data. + @need 1750 @item -y @itemx --yacc @@ -6714,6 +6792,7 @@ the corresponding short option. \line{ --no-lines \leaderfill -l} \line{ --no-parser \leaderfill -n} \line{ --output \leaderfill -o} +\line{ --print-localedir} \line{ --token-table \leaderfill -k} \line{ --verbose \leaderfill -v} \line{ --version \leaderfill -V} @@ -6732,6 +6811,7 @@ the corresponding short option. --no-lines -l --no-parser -n --output=@var{outfile} -o @var{outfile} +--print-localedir --token-table -k --verbose -v --version -V diff --git a/m4/bison-i18n.m4 b/m4/bison-i18n.m4 new file mode 100644 index 00000000..2fe6c604 --- /dev/null +++ b/m4/bison-i18n.m4 @@ -0,0 +1,59 @@ +# bison-i18n.m4 serial 1 (bison-2.1) +dnl Copyright (C) 2005 Free Software Foundation, Inc. +dnl This file is free software; the Free Software Foundation +dnl gives unlimited permission to copy and/or distribute it, +dnl with or without modifications, as long as this notice is preserved. + +dnl From Bruno Haible. + +dnl Support for internationalization of bison-generated parsers. + +dnl BISON_I18N +dnl should be used in configure.ac, after AM_GNU_GETTEXT. If USE_NLS is yes, it +dnl sets BISON_LOCALEDIR to indicate where to find the bison-runtime.mo files +dnl and defines YYENABLE_NLS if there are bison-runtime.mo files at all. +AC_DEFUN([BISON_I18N], +[ + if test -z "$USE_NLS"; then + echo "The BISON-I18N macro is used without being preceded by AM-GNU-GETTEXT." 1>&2 + exit 1 + fi + BISON_LOCALEDIR= + if test "$USE_NLS" = yes; then + dnl AC_PROG_YACC sets the YACC variable; other macros set the BISON variable. + if test -n "$YACC"; then + case "$YACC" in + *bison*) + if ($YACC --print-localedir) >/dev/null 2>&1; then + BISON_LOCALEDIR=`$YACC --print-localedir` + fi + ;; + esac + else + if test -n "$BISON"; then + if test "$BISON" != ":"; then + if ($BISON --print-localedir) >/dev/null 2>&1; then + BISON_LOCALEDIR=`$BISON --print-localedir` + fi + fi + fi + fi + AC_SUBST([BISON_LOCALEDIR]) + if test -n "$BISON_LOCALEDIR"; then + USER_LINGUAS="${LINGUAS-%UNSET%}" + if test -n "$USER_LINGUAS"; then + BISON_USE_NLS=yes + else + BISON_USE_NLS=no + fi + else + BISON_USE_NLS=no + fi + else + BISON_USE_NLS=no + fi + if test $BISON_USE_NLS = yes; then + AC_DEFINE([YYENABLE_NLS], 1, + [Define to 1 to internationalize bison runtime messages.]) + fi +]) diff --git a/po/POTFILES.in b/po/POTFILES.in index 4b96f6f5..ea193b14 100644 --- a/po/POTFILES.in +++ b/po/POTFILES.in @@ -4,7 +4,6 @@ src/files.c src/getargs.c src/gram.c src/main.c -src/parse-gram.c src/parse-gram.y src/print.c src/reader.c diff --git a/runtime-po/.cvsignore b/runtime-po/.cvsignore new file mode 100644 index 00000000..edf04572 --- /dev/null +++ b/runtime-po/.cvsignore @@ -0,0 +1,17 @@ +*.gmo +*.po +LINGUAS +Makefile +Makefile.in +Makevars +POTFILES +Rules-quot +bison-runtime.old.pot +boldquot.sed +en@boldquot.header +en@quot.header +insert-header.sin +quot.sed +remove-potcdate.sed +remove-potcdate.sin +stamp-po diff --git a/runtime-po/Makefile.in.in b/runtime-po/Makefile.in.in new file mode 100644 index 00000000..2aee216a --- /dev/null +++ b/runtime-po/Makefile.in.in @@ -0,0 +1,356 @@ +# Makefile for PO directory in any package using GNU gettext. +# Copyright (C) 1995-1997, 2000-2003 by Ulrich Drepper +# +# This file can be copied and used freely without restrictions. It can +# be used in projects which are not available under the GNU General Public +# License but which still want to provide support for the GNU gettext +# functionality. +# Please note that the actual code of GNU gettext is covered by the GNU +# General Public License and is *not* in the public domain. + +PACKAGE = @PACKAGE@ +VERSION = @VERSION@ + +SHELL = /bin/sh +@SET_MAKE@ + +srcdir = @srcdir@ +top_srcdir = @top_srcdir@ +VPATH = @srcdir@ + +prefix = @prefix@ +exec_prefix = @exec_prefix@ +datadir = @datadir@ +localedir = $(datadir)/locale +gettextsrcdir = $(datadir)/gettext/po + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +MKINSTALLDIRS = @MKINSTALLDIRS@ +mkinstalldirs = $(SHELL) $(MKINSTALLDIRS) + +GMSGFMT = @GMSGFMT@ +MSGFMT = @MSGFMT@ +XGETTEXT = @XGETTEXT@ +MSGMERGE = msgmerge +MSGMERGE_UPDATE = @MSGMERGE@ --update +MSGINIT = msginit +MSGCONV = msgconv +MSGFILTER = msgfilter + +POFILES = @POFILES@ +GMOFILES = @GMOFILES@ +UPDATEPOFILES = @UPDATEPOFILES@ +DUMMYPOFILES = @DUMMYPOFILES@ +DISTFILES.common = Makefile.in.in remove-potcdate.sin \ +$(DISTFILES.common.extra1) $(DISTFILES.common.extra2) $(DISTFILES.common.extra3) +DISTFILES = $(DISTFILES.common) Makevars POTFILES.in $(DOMAIN).pot stamp-po \ +$(POFILES) $(GMOFILES) \ +$(DISTFILES.extra1) $(DISTFILES.extra2) $(DISTFILES.extra3) + +POTFILES = \ + +CATALOGS = @CATALOGS@ + +# Makevars gets inserted here. (Don't remove this line!) + +.SUFFIXES: +.SUFFIXES: .po .gmo .mo .sed .sin .nop .po-update + +.po.mo: + @echo "$(MSGFMT) -c -o $@ $<"; \ + $(MSGFMT) -c -o t-$@ $< && mv t-$@ $@ + +.po.gmo: + @lang=`echo $* | sed -e 's,.*/,,'`; \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o $${lang}.gmo $${lang}.po"; \ + cd $(srcdir) && rm -f $${lang}.gmo && $(GMSGFMT) -c --statistics -o t-$${lang}.gmo $${lang}.po && mv t-$${lang}.gmo $${lang}.gmo + +.sin.sed: + sed -e '/^#/d' $< > t-$@ + mv t-$@ $@ + + +all: all-@USE_NLS@ + +all-yes: stamp-po +all-no: + +# stamp-po is a timestamp denoting the last time at which the CATALOGS have +# been loosely updated. Its purpose is that when a developer or translator +# checks out the package via CVS, and the $(DOMAIN).pot file is not in CVS, +# "make" will update the $(DOMAIN).pot and the $(CATALOGS), but subsequent +# invocations of "make" will do nothing. This timestamp would not be necessary +# if updating the $(CATALOGS) would always touch them; however, the rule for +# $(POFILES) has been designed to not touch files that don't need to be +# changed. +stamp-po: $(srcdir)/$(DOMAIN).pot + test -z "$(CATALOGS)" || $(MAKE) $(CATALOGS) + @echo "touch stamp-po" + @echo timestamp > stamp-poT + @mv stamp-poT stamp-po + +# Note: Target 'all' must not depend on target '$(DOMAIN).pot-update', +# otherwise packages like GCC can not be built if only parts of the source +# have been downloaded. + +# This target rebuilds $(DOMAIN).pot; it is an expensive operation. +# Note that $(DOMAIN).pot is not touched if it doesn't need to be changed. +$(DOMAIN).pot-update: $(POTFILES) $(srcdir)/POTFILES.in remove-potcdate.sed + $(XGETTEXT) -o $(DOMAIN).old.pot --no-location $(DOMAIN).pot && \ + $(XGETTEXT) --default-domain=$(DOMAIN) --directory=$(top_srcdir) \ + --add-comments=TRANSLATORS: $(XGETTEXT_OPTIONS) \ + --files-from=$(srcdir)/POTFILES.in $(subdir)/$(DOMAIN).old.pot \ + --copyright-holder='$(COPYRIGHT_HOLDER)' \ + --msgid-bugs-address='$(MSGID_BUGS_ADDRESS)' + rm -f $(DOMAIN).old.pot + test ! -f $(DOMAIN).po || { \ + if test -f $(srcdir)/$(DOMAIN).pot; then \ + sed -f remove-potcdate.sed < $(srcdir)/$(DOMAIN).pot > $(DOMAIN).1po && \ + sed -f remove-potcdate.sed < $(DOMAIN).po > $(DOMAIN).2po && \ + if cmp $(DOMAIN).1po $(DOMAIN).2po >/dev/null 2>&1; then \ + rm -f $(DOMAIN).1po $(DOMAIN).2po $(DOMAIN).po; \ + else \ + rm -f $(DOMAIN).1po $(DOMAIN).2po $(srcdir)/$(DOMAIN).pot && \ + mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ + fi; \ + else \ + mv $(DOMAIN).po $(srcdir)/$(DOMAIN).pot; \ + fi; \ + } + +# This rule has no dependencies: we don't need to update $(DOMAIN).pot at +# every "make" invocation, only create it when it is missing. +# Only "make $(DOMAIN).pot-update" or "make dist" will force an update. +$(srcdir)/$(DOMAIN).pot: + $(MAKE) $(DOMAIN).pot-update + +# This target rebuilds a PO file if $(DOMAIN).pot has changed. +# Note that a PO file is not touched if it doesn't need to be changed. +$(POFILES): $(srcdir)/$(DOMAIN).pot + @lang=`echo $@ | sed -e 's,.*/,,' -e 's/\.po$$//'`; \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}$(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot"; \ + cd $(srcdir) && $(MSGMERGE_UPDATE) $${lang}.po $(DOMAIN).pot + + +install: install-exec install-data +install-exec: +install-data: install-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \ + for file in $(DISTFILES.common) Makevars.template; do \ + $(INSTALL_DATA) $(srcdir)/$$file \ + $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + for file in Makevars; do \ + rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + else \ + : ; \ + fi +install-data-no: all +install-data-yes: all + $(mkinstalldirs) $(DESTDIR)$(datadir) + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + dir=$(localedir)/$$lang/LC_MESSAGES; \ + $(mkinstalldirs) $(DESTDIR)$$dir; \ + if test -r $$cat; then realcat=$$cat; else realcat=$(srcdir)/$$cat; fi; \ + $(INSTALL_DATA) $$realcat $(DESTDIR)$$dir/$(DOMAIN).mo; \ + echo "installing $$realcat as $(DESTDIR)$$dir/$(DOMAIN).mo"; \ + for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ + if test -n "$$lc"; then \ + if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ + link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ + mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ + for file in *; do \ + if test -f $$file; then \ + ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ + fi; \ + done); \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + else \ + if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ + :; \ + else \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + fi; \ + fi; \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + ln -s ../LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ + ln $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo 2>/dev/null || \ + cp -p $(DESTDIR)$(localedir)/$$lang/LC_MESSAGES/$(DOMAIN).mo $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + echo "installing $$realcat link as $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo"; \ + fi; \ + done; \ + done + +install-strip: install + +installdirs: installdirs-exec installdirs-data +installdirs-exec: +installdirs-data: installdirs-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + $(mkinstalldirs) $(DESTDIR)$(gettextsrcdir); \ + else \ + : ; \ + fi +installdirs-data-no: +installdirs-data-yes: + $(mkinstalldirs) $(DESTDIR)$(datadir) + @catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + dir=$(localedir)/$$lang/LC_MESSAGES; \ + $(mkinstalldirs) $(DESTDIR)$$dir; \ + for lc in '' $(EXTRA_LOCALE_CATEGORIES); do \ + if test -n "$$lc"; then \ + if (cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc 2>/dev/null) | grep ' -> ' >/dev/null; then \ + link=`cd $(DESTDIR)$(localedir)/$$lang && LC_ALL=C ls -l -d $$lc | sed -e 's/^.* -> //'`; \ + mv $(DESTDIR)$(localedir)/$$lang/$$lc $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + (cd $(DESTDIR)$(localedir)/$$lang/$$lc.old && \ + for file in *; do \ + if test -f $$file; then \ + ln -s ../$$link/$$file $(DESTDIR)$(localedir)/$$lang/$$lc/$$file; \ + fi; \ + done); \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc.old; \ + else \ + if test -d $(DESTDIR)$(localedir)/$$lang/$$lc; then \ + :; \ + else \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc; \ + mkdir $(DESTDIR)$(localedir)/$$lang/$$lc; \ + fi; \ + fi; \ + fi; \ + done; \ + done + +# Define this as empty until I found a useful application. +installcheck: + +uninstall: uninstall-exec uninstall-data +uninstall-exec: +uninstall-data: uninstall-data-@USE_NLS@ + if test "$(PACKAGE)" = "gettext-tools"; then \ + for file in $(DISTFILES.common) Makevars.template; do \ + rm -f $(DESTDIR)$(gettextsrcdir)/$$file; \ + done; \ + else \ + : ; \ + fi +uninstall-data-no: +uninstall-data-yes: + catalogs='$(CATALOGS)'; \ + for cat in $$catalogs; do \ + cat=`basename $$cat`; \ + lang=`echo $$cat | sed -e 's/\.gmo$$//'`; \ + for lc in LC_MESSAGES $(EXTRA_LOCALE_CATEGORIES); do \ + rm -f $(DESTDIR)$(localedir)/$$lang/$$lc/$(DOMAIN).mo; \ + done; \ + done + +check: all + +info dvi ps pdf html tags TAGS ctags CTAGS ID: + +mostlyclean: + rm -f remove-potcdate.sed + rm -f stamp-poT + rm -f core core.* $(DOMAIN).po $(DOMAIN).1po $(DOMAIN).2po *.new.po + rm -f *.old.pot + rm -fr *.o + +clean: mostlyclean + +distclean: clean + rm -f Makefile Makefile.in POTFILES *.mo + +maintainer-clean: distclean + @echo "This command is intended for maintainers to use;" + @echo "it deletes files that may require special tools to rebuild." + rm -f stamp-po $(GMOFILES) + +distdir = $(top_builddir)/$(PACKAGE)-$(VERSION)/$(subdir) +dist distdir: + $(MAKE) update-po + @$(MAKE) dist2 +# This is a separate target because 'update-po' must be executed before. +dist2: $(DISTFILES) + dists="$(DISTFILES)"; \ + if test "$(PACKAGE)" = "gettext-tools"; then \ + dists="$$dists Makevars.template"; \ + fi; \ + if test -f $(srcdir)/ChangeLog; then \ + dists="$$dists ChangeLog"; \ + fi; \ + for i in 0 1 2 3 4 5 6 7 8 9; do \ + if test -f $(srcdir)/ChangeLog.$$i; then \ + dists="$$dists ChangeLog.$$i"; \ + fi; \ + done; \ + if test -f $(srcdir)/LINGUAS; then dists="$$dists LINGUAS"; fi; \ + for file in $$dists; do \ + if test -f $$file; then \ + cp -p $$file $(distdir); \ + else \ + cp -p $(srcdir)/$$file $(distdir); \ + fi; \ + done + +update-po: Makefile + $(MAKE) $(DOMAIN).pot-update + test -z "$(UPDATEPOFILES)" || $(MAKE) $(UPDATEPOFILES) + $(MAKE) update-gmo + +# General rule for updating PO files. + +.nop.po-update: + @lang=`echo $@ | sed -e 's/\.po-update$$//'`; \ + if test "$(PACKAGE)" = "gettext-tools"; then PATH=`pwd`/../src:$$PATH; fi; \ + tmpdir=`pwd`; \ + echo "$$lang:"; \ + test "$(srcdir)" = . && cdcmd="" || cdcmd="cd $(srcdir) && "; \ + echo "$${cdcmd}$(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$lang.new.po"; \ + cd $(srcdir); \ + if $(MSGMERGE) $$lang.po $(DOMAIN).pot -o $$tmpdir/$$lang.new.po; then \ + if cmp $$lang.po $$tmpdir/$$lang.new.po >/dev/null 2>&1; then \ + rm -f $$tmpdir/$$lang.new.po; \ + else \ + if mv -f $$tmpdir/$$lang.new.po $$lang.po; then \ + :; \ + else \ + echo "msgmerge for $$lang.po failed: cannot move $$tmpdir/$$lang.new.po to $$lang.po" 1>&2; \ + exit 1; \ + fi; \ + fi; \ + else \ + echo "msgmerge for $$lang.po failed!" 1>&2; \ + rm -f $$tmpdir/$$lang.new.po; \ + fi + +$(DUMMYPOFILES): + +update-gmo: Makefile $(GMOFILES) + @: + +Makefile: Makefile.in.in $(top_builddir)/config.status @POMAKEFILEDEPS@ + cd $(top_builddir) \ + && CONFIG_FILES=$(subdir)/$@.in CONFIG_HEADERS= \ + $(SHELL) ./config.status + +force: + +# Tell versions [3.59,3.63) of GNU make not to export all variables. +# Otherwise a system limit (for SysV at least) may be exceeded. +.NOEXPORT: diff --git a/runtime-po/POTFILES.in b/runtime-po/POTFILES.in new file mode 100644 index 00000000..ca81b5e5 --- /dev/null +++ b/runtime-po/POTFILES.in @@ -0,0 +1 @@ +data/yacc.c diff --git a/runtime-po/bison-runtime.pot b/runtime-po/bison-runtime.pot new file mode 100644 index 00000000..ed1b6bb9 --- /dev/null +++ b/runtime-po/bison-runtime.pot @@ -0,0 +1,105 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR Free Software Foundation, Inc. +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: bug-bison@gnu.org\n" +"POT-Creation-Date: 2005-06-27 00:48+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: data/yacc.c:520 +msgid "syntax error: cannot back up" +msgstr "" + +#: data/yacc.c:614 +msgid "Stack now" +msgstr "" + +#: data/yacc.c:636 +#, c-format +msgid "Reducing stack by rule %d (line %u), " +msgstr "" + +#: data/yacc.c:905 data/yacc.c:1315 +msgid "parser stack overflow" +msgstr "" + +#: data/yacc.c:945 +#, c-format +msgid "Stack size increased to %lu\n" +msgstr "" + +#: data/yacc.c:952 +#, c-format +msgid "Entering state %d\n" +msgstr "" + +#: data/yacc.c:976 +msgid "Reading a token: " +msgstr "" + +#: data/yacc.c:983 +msgid "Now at end of input.\n" +msgstr "" + +#: data/yacc.c:988 +msgid "Next token is" +msgstr "" + +#: data/yacc.c:1009 data/yacc.c:1290 +msgid "Shifting" +msgstr "" + +#: data/yacc.c:1117 +#, c-format +msgid "syntax error, unexpected %s" +msgstr "" + +#: data/yacc.c:1118 +#, c-format +msgid "syntax error, unexpected %s, expecting %s" +msgstr "" + +#: data/yacc.c:1119 +#, c-format +msgid "syntax error, unexpected %s, expecting %s or %s" +msgstr "" + +#: data/yacc.c:1120 +#, c-format +msgid "syntax error, unexpected %s, expecting %s or %s or %s" +msgstr "" + +#: data/yacc.c:1121 +#, c-format +msgid "syntax error, unexpected %s, expecting %s or %s or %s or %s" +msgstr "" + +#: data/yacc.c:1195 +msgid "syntax error; also memory exhausted" +msgstr "" + +#: data/yacc.c:1199 +msgid "syntax error" +msgstr "" + +#: data/yacc.c:1218 +msgid "Error: discarding" +msgstr "" + +#: data/yacc.c:1272 data/yacc.c:1331 +msgid "Error: popping" +msgstr "" + +#: data/yacc.c:1322 +msgid "Error: discarding lookahead" +msgstr "" diff --git a/src/getargs.c b/src/getargs.c index 515b8583..1a0432e7 100644 --- a/src/getargs.c +++ b/src/getargs.c @@ -207,9 +207,10 @@ for the equivalent short option also. Similarly for optional arguments.\n"), fputs (_("\ Operation modes:\n\ - -h, --help display this help and exit\n\ - -V, --version output version information and exit\n\ - -y, --yacc emulate POSIX yacc\n"), stdout); + -h, --help display this help and exit\n\ + -V, --version output version information and exit\n\ + --print-localedir output directory containing locale-dependent data\n\ + -y, --yacc emulate POSIX yacc\n"), stdout); putc ('\n', stdout); fputs (_("\ @@ -289,14 +290,16 @@ const char *short_options = "yvegdhr:ltknVo:b:p:S:T::"; /* Values for long options that do not have single-letter equivalents. */ enum { - LOCATIONS_OPTION = CHAR_MAX + 1 + LOCATIONS_OPTION = CHAR_MAX + 1, + PRINT_LOCALEDIR_OPTION }; static struct option const long_options[] = { /* Operation modes. */ - { "help", no_argument, 0, 'h' }, - { "version", no_argument, 0, 'V' }, + { "help", no_argument, 0, 'h' }, + { "version", no_argument, 0, 'V' }, + { "print-localedir", no_argument, 0, PRINT_LOCALEDIR_OPTION }, /* Parser. */ { "name-prefix", required_argument, 0, 'p' }, @@ -364,6 +367,10 @@ getargs (int argc, char *argv[]) version (); exit (EXIT_SUCCESS); + case PRINT_LOCALEDIR_OPTION: + printf ("%s\n", LOCALEDIR); + exit (EXIT_SUCCESS); + case 'g': /* Here, the -g and --graph=FILE options are differentiated. */ graph_flag = true; diff --git a/src/main.c b/src/main.c index cd68c903..b2f85599 100644 --- a/src/main.c +++ b/src/main.c @@ -56,8 +56,9 @@ main (int argc, char *argv[]) { program_name = argv[0]; setlocale (LC_ALL, ""); - (void) bindtextdomain (PACKAGE, LOCALEDIR); - (void) textdomain (PACKAGE); + bindtextdomain (PACKAGE, LOCALEDIR); + bindtextdomain ("bison-runtime", LOCALEDIR); + textdomain (PACKAGE); uniqstrs_new ();