OSDN Git Service

ch:
[pf3gnuchains/gcc-fork.git] / gcc / ABOUT-GCC-NLS
1 Notes on GCC's Native Language Support
2
3 By and large, only diagnostic messages have been internationalized.
4 Some work remains in other areas; for example, GCC does not yet allow
5 non-ASCII letters in identifiers.
6
7 Not all of GCC's diagnostic messages have been internationalized. Programs
8 like `enquire' and `genattr' (in fact all gen* programs) are not
9 internationalized, as their users are GCC maintainers who typically need to
10 be able to read English anyway; internationalizing them would thus entail
11 needless work for the human translators. Messages used for debugging, such
12 as used in dumped tables, should also not be translated.
13
14 The GCC library should not contain any messages that need
15 internationalization, because it operates below the internationalization
16 library.
17
18 Currently, the only language translation supplied is en_UK (British English).
19
20 Unlike some other GNU programs, the GCC sources contain few instances
21 of explicit translation calls like _("string").  Instead, the
22 diagnostic printing routines automatically translate their arguments.
23 For example, GCC source code should not contain calls like `error
24 (_("unterminated comment"))'; it should contain calls like `error
25 ("unterminated comment")' instead, as it is the `error' function's
26 responsibility to translate the message before the user sees it.
27
28 By convention, any function parameter in the GCC sources whose name
29 ends in `msgid' is expected to be a message requiring translation.
30 For example, the `error' function's first parameter is named `msgid'.
31 GCC's exgettext script uses this convention to determine which
32 function parameter strings need to be translated.  The exgettext
33 script also assumes that any occurrence of `%eMSGID}' on a source
34 line, where MSGID does not contain `%' or `}', corresponds to a
35 message MSGID that requires translation; this is needed to identify
36 diagnostics in GCC spec strings.
37
38 If you modify source files, you'll need to use a special
39 version of the GNU gettext package to propagate the modifications to the
40 translation tables.
41
42 Paul Eggerts original patches have been incorporated into the official
43 gettext CVS. These sources may be accessed via anonymous cvs. The root for
44 the gettext CVS is :pserver:anoncvs@anoncvs.cygnus.com:/cvs/gettext 
45 Password is `anoncvs' like for the GCC CVS. After having retrieved the
46 sources, you have to apply the following patch, which is pending approval by
47 the gettext maintainer.
48
49 After having built and installed these gettext tools, you have to configure
50 GCC with --enable-maintainer-mode to get the master catalog rebuilt.
51
52 2000-06-01  Martin v. Löwis  <loewis@informatik.hu-berlin.de>
53
54         * xgettext.c (long_options): New option defines.
55         * xget-lex.c (phase6_get): If set, process #defines as well.
56
57 --- doc/gettext.texi    2000/07/28 21:11:32     1.2
58 +++ doc/gettext.texi    2000/08/27 23:28:32
59 @@ -20,7 +20,7 @@
60  This file provides documentation for GNU @code{gettext} utilities.
61  It also serves as a reference for the free Translation Project.
62  
63 -Copyright (C) 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
64 +Copyright (C) 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
65  
66  Permission is granted to make and distribute verbatim copies of
67  this manual provided the copyright notice and this permission notice
68 @@ -54,7 +54,7 @@ by the Foundation.
69  
70  @page
71  @vskip 0pt plus 1filll
72 -Copyright @copyright{} 1995, 1996, 1997, 1998 Free Software Foundation, Inc.
73 +Copyright @copyright{} 1995, 1996, 1997, 1998, 2000 Free Software Foundation, Inc.
74  
75  Permission is granted to make and distribute verbatim copies of
76  this manual provided the copyright notice and this permission notice
77 @@ -1828,6 +1828,10 @@ not have to care about these details.
78  @item -d @var{name}
79  @itemx --default-domain=@var{name}
80  Use @file{@var{name}.po} for output (instead of @file{messages.po}).
81 +
82 +@itemx --defines
83 +Look for the keywords in #define statements as well. Normally, xgettext
84 +will treat them as white space.
85  
86  The special domain name @file{-} or @file{/dev/stdout} means to write
87  the output to @file{stdout}.
88
89 --- src/xget-lex.c      2000/07/28 21:11:32     1.2
90 +++ src/xget-lex.c      2000/08/27 23:28:33
91 @@ -1045,6 +1045,7 @@ phaseX_get (tp)
92  static token_ty phase6_pushback[4];
93  static int phase6_pushback_length;
94  
95 +extern int defines;
96  
97  static void
98  phase6_get (tp)
99 @@ -1068,9 +1069,36 @@ phase6_get (tp)
100        if (tp->type != token_type_hash)
101         return;
102  
103 +      /* Find the first non-whitespace token. If it is a define, we
104 +        will treat the rest of the line as normal input, if defines
105 +        is set. */
106 +      if (defines)
107 +       {
108 +         while (1)
109 +           {
110 +             phaseX_get (tp);
111 +             if (tp->type == token_type_eoln || tp->type == token_type_eof)
112 +               return;
113 +             if (tp->type != token_type_white_space)
114 +               break;
115 +           }
116 +         if (tp->type == token_type_name 
117 +             && strcmp (tp->string, "define") == 0)
118 +           return;
119 +         /* It's not a define, so we start collecting tokens.  */
120 +         if (!bufmax)
121 +           {
122 +             bufmax = 100;
123 +             buf = xrealloc (buf, bufmax * sizeof (buf[0]));
124 +           }
125 +         buf[0] = *tp;
126 +         bufpos = 1;
127 +       }
128 +      else
129 +       bufpos = 0;
130 +
131        /* Accumulate the rest of the directive in a buffer.  Work out
132          what it is later.  */
133 -      bufpos = 0;
134        while (1)
135         {
136           phaseX_get (tp);
137
138 --- src/xgettext.c      2000/07/28 21:11:32     1.2
139 +++ src/xgettext.c      2000/08/27 23:28:35
140 @@ -80,6 +80,9 @@ static char *comment_tag;
141  /* Name of default domain file.  If not set defaults to messages.po.  */
142  static char *default_domain;
143  
144 +/* If preprocessor defines are also analyzed for keywords.  */
145 +int defines;
146 +
147  /* If called with --debug option the output reflects whether format
148     string recognition is done automatically or forced by the user.  */
149  static int do_debug;
150 @@ -125,6 +128,7 @@ static const struct option long_options[
151    { "debug", no_argument, &do_debug, 1 },
152    { "default-domain", required_argument, NULL, 'd' },
153    { "directory", required_argument, NULL, 'D' },
154 +  { "defines", no_argument, &defines, 1 },
155    { "escape", no_argument, NULL, 'E' },
156    { "exclude-file", required_argument, NULL, 'x' },
157    { "extract-all", no_argument, &extract_all, 1 },
158 @@ -552,6 +556,7 @@ Mandatory arguments to long options are 
159    -C, --c++                      shorthand for --language=C++\n\
160        --debug                    more detailed formatstring recognision result\n\
161    -d, --default-domain=NAME      use NAME.po for output (instead of messages.po)\n\
162 +      --defines                  analyze preprocessor defines\n\
163    -D, --directory=DIRECTORY      add DIRECTORY to list for input files search\n\
164    -e, --no-escape                do not use C escapes in output (default)\n\
165    -E, --escape                   use C escapes in output, no extended chars\n\
166
167