From 2c748729910a088e746225fa1eb238cd5419e295 Mon Sep 17 00:00:00 2001 From: Akim Demaille Date: Mon, 30 Mar 2020 07:51:15 +0200 Subject: [PATCH] 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. --- TODO | 1 + data/skeletons/c.m4 | 2 ++ data/skeletons/java.m4 | 8 +++++--- examples/java/calc/Calc.y | 9 +++++---- tests/calc.at | 2 +- 5 files changed, 14 insertions(+), 8 deletions(-) diff --git a/TODO b/TODO index 3d45888f..196af194 100644 --- a/TODO +++ b/TODO @@ -3,6 +3,7 @@ - yyexpected_tokens in all the languages. - remove yysyntax_error_arguments. - YYNOMEM +- i18n in Java ** Naming conventions yysyntax_error_arguments should be yy_syntax_error_arguments, since it's a diff --git a/data/skeletons/c.m4 b/data/skeletons/c.m4 index 06610ecb..eaa1dba8 100644 --- a/data/skeletons/c.m4 +++ b/data/skeletons/c.m4 @@ -479,6 +479,8 @@ m4_define([b4_token_enums_defines], # b4_symbol_translate(STRING) # --------------------------- +# Used by "bison" in the array of symbol names to mark those that +# require translation. m4_define([b4_symbol_translate], [[N_($1)]]) diff --git a/data/skeletons/java.m4 b/data/skeletons/java.m4 index 984fd3ea..6b8fe514 100644 --- a/data/skeletons/java.m4 +++ b/data/skeletons/java.m4 @@ -229,15 +229,17 @@ m4_define([b4_position_type], [b4_percent_define_get([[api.position.type]])]) # b4_symbol_translate(STRING) # --------------------------- +# Used by "bison" in the array of symbol names to mark those that +# require translation. m4_define([b4_symbol_translate], -[[_($1)]]) +[[i18n($1)]]) # 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_if(b4_has_translations, 0, [$1], [_($1)])]) +[m4_if(b4_has_translations, 0, [$1], [i18n($1)])]) diff --git a/examples/java/calc/Calc.y b/examples/java/calc/Calc.y index 4bb01c72..dc502671 100644 --- a/examples/java/calc/Calc.y +++ b/examples/java/calc/Calc.y @@ -19,7 +19,7 @@ } %code { - public static void main (String[] args) throws IOException + public static void main(String[] args) throws IOException { CalcLexer l = new CalcLexer (System.in); Calc p = new Calc (l); @@ -30,7 +30,7 @@ System.exit (1); } - static String _ (String s) + static String i18n(String s) { return s; } @@ -38,8 +38,9 @@ /* Bison Declarations */ %token - '\n' _("end of line") - NUM _("number") + '\n' _("end of line") + + NUM _("number") %type exp %nonassoc '=' /* comparison */ diff --git a/tests/calc.at b/tests/calc.at index 401c5ffa..8a3122aa 100644 --- a/tests/calc.at +++ b/tests/calc.at @@ -669,7 +669,7 @@ m4_define([_AT_DATA_CALC_Y(java)], ]AT_CALC_MAIN[ ]AT_TOKEN_TRANSLATE_IF([[ - static String _ (String s) + static String i18n(String s) { if (s.equals ("end of input")) return "end of file";