mirror of
https://git.savannah.gnu.org/git/bison.git
synced 2026-03-09 12:23:04 +00:00
java: make the syntax error format string translatable
The error format should be translated, but contrary to the case of C/C++, we cannot just depend on macros to adapt on the presence/absence of '_'. Let's consider that the message format is to be translated iff there are some internationalized tokens. * src/output.c (prepare_symbol_names): Define b4_has_translations. * data/skeletons/java.m4 (b4_trans): New. * data/skeletons/lalr1.java: Use it to emit translatable or not the format string.
This commit is contained in:
@@ -945,18 +945,18 @@ b4_dollar_popdef[]dnl
|
||||
String[] yystr = new String[yycount];
|
||||
for (int yyi = 0; yyi < yycount; ++yyi)
|
||||
yystr[yyi] = yysymbolName (yyarg[yyi]);
|
||||
MessageFormat yyformat;
|
||||
String yyformat;
|
||||
switch (yycount)
|
||||
{
|
||||
default:
|
||||
case 0: yyformat = new MessageFormat ("syntax error"); break;
|
||||
case 1: yyformat = new MessageFormat ("syntax error, unexpected {0}"); break;
|
||||
case 2: yyformat = new MessageFormat ("syntax error, unexpected {0}, expecting {1}"); break;
|
||||
case 3: yyformat = new MessageFormat ("syntax error, unexpected {0}, expecting {1} or {2}"); break;
|
||||
case 4: yyformat = new MessageFormat ("syntax error, unexpected {0}, expecting {1} or {2} or {3}"); break;
|
||||
case 5: yyformat = new MessageFormat ("syntax error, unexpected {0}, expecting {1} or {2} or {3} or {4}"); break;
|
||||
case 0: yyformat = ]b4_trans(["syntax error"])[; break;
|
||||
case 1: yyformat = ]b4_trans(["syntax error, unexpected {0}"])[; break;
|
||||
case 2: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1}"])[; break;
|
||||
case 3: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2}"])[; break;
|
||||
case 4: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2} or {3}"])[; break;
|
||||
case 5: yyformat = ]b4_trans(["syntax error, unexpected {0}, expecting {1} or {2} or {3} or {4}"])[; break;
|
||||
}
|
||||
return yyformat.format (yystr);
|
||||
return new MessageFormat (yyformat).format (yystr);
|
||||
}
|
||||
]])[
|
||||
return "syntax error";
|
||||
|
||||
Reference in New Issue
Block a user