Previous: , Up: Internationalization   [Contents][Index]


4.6.2 Token Internationalization

When the %define variable parse.error is set to custom or detailed, token aliases can be internationalized:

%token
    '\n'   _("end of line")
  <double>
    NUM    _("number")
  <symrec*>
    FUN    _("function")
    VAR    _("variable")

The remainder of the grammar may freely use either the token symbol (FUN) or its alias ("function"), but not with the internationalization marker (_("function")).

If at least one token alias is internationalized, then the generated parser will use both N_ and _, that must be defined (see The Programmer’s View in GNU gettext utilities). They are used only on string aliases marked for translation. In other words, even if your catalog features a translation for “function”, then with

%token
  <symrec*>
    FUN      "function"
    VAR    _("variable")

“function” will appear untranslated in debug traces and error messages.

Unless defined by the user, the end-of-file token, YYEOF, is provided “end of file” as an alias. It is also internationalized if the user internationalized tokens. To map it to another string, use:

%token END 0 _("end of input")