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";