java: move away from _ for internationalization

The "_" is becoming a keyword in Java, which causes tons of warnings
currently in our test suite.  GNU Gettext is now using "i18n" instead
of "_"
(https://git.savannah.gnu.org/gitweb/?p=gettext.git;a=commitdiff;h=e89fea36545f27487d9652a13e6a0adbea1117d0).

* data/skeletons/java.m4: Use "i18n", not "_".
* examples/java/calc/Calc.y, tests/calc.at: Adjust.
This commit is contained in:
Akim Demaille
2020-03-30 07:51:15 +02:00
parent 50517d578c
commit 2c74872991
5 changed files with 14 additions and 8 deletions

1
TODO
View File

@@ -3,6 +3,7 @@
- yyexpected_tokens in all the languages. - yyexpected_tokens in all the languages.
- remove yysyntax_error_arguments. - remove yysyntax_error_arguments.
- YYNOMEM - YYNOMEM
- i18n in Java
** Naming conventions ** Naming conventions
yysyntax_error_arguments should be yy_syntax_error_arguments, since it's a yysyntax_error_arguments should be yy_syntax_error_arguments, since it's a

View File

@@ -479,6 +479,8 @@ m4_define([b4_token_enums_defines],
# b4_symbol_translate(STRING) # b4_symbol_translate(STRING)
# --------------------------- # ---------------------------
# Used by "bison" in the array of symbol names to mark those that
# require translation.
m4_define([b4_symbol_translate], m4_define([b4_symbol_translate],
[[N_($1)]]) [[N_($1)]])

View File

@@ -229,15 +229,17 @@ m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])])
# b4_symbol_translate(STRING) # b4_symbol_translate(STRING)
# --------------------------- # ---------------------------
# Used by "bison" in the array of symbol names to mark those that
# require translation.
m4_define([b4_symbol_translate], m4_define([b4_symbol_translate],
[[_($1)]]) [[i18n($1)]])
# b4_trans(STRING) # b4_trans(STRING)
# ---------------- # ----------------
# Translate a symbol. Avoid collision with b4_translate. # Translate a string if i18n is enabled. Avoid collision with b4_translate.
m4_define([b4_trans], m4_define([b4_trans],
[m4_if(b4_has_translations, 0, [$1], [_($1)])]) [m4_if(b4_has_translations, 0, [$1], [i18n($1)])])

View File

@@ -19,7 +19,7 @@
} }
%code { %code {
public static void main (String[] args) throws IOException public static void main(String[] args) throws IOException
{ {
CalcLexer l = new CalcLexer (System.in); CalcLexer l = new CalcLexer (System.in);
Calc p = new Calc (l); Calc p = new Calc (l);
@@ -30,7 +30,7 @@
System.exit (1); System.exit (1);
} }
static String _ (String s) static String i18n(String s)
{ {
return s; return s;
} }
@@ -38,8 +38,9 @@
/* Bison Declarations */ /* Bison Declarations */
%token %token
'\n' _("end of line") '\n' _("end of line")
<Integer> NUM _("number") <Integer>
NUM _("number")
%type <Integer> exp %type <Integer> exp
%nonassoc '=' /* comparison */ %nonassoc '=' /* comparison */

View File

@@ -669,7 +669,7 @@ m4_define([_AT_DATA_CALC_Y(java)],
]AT_CALC_MAIN[ ]AT_CALC_MAIN[
]AT_TOKEN_TRANSLATE_IF([[ ]AT_TOKEN_TRANSLATE_IF([[
static String _ (String s) static String i18n(String s)
{ {
if (s.equals ("end of input")) if (s.equals ("end of input"))
return "end of file"; return "end of file";