1 Notes on GCC's Native Language Support
3 GCC's Native Language Support (NLS) is relatively new and
4 experimental, so NLS is currently disabled by default. Use
5 configure's --enable-nls option to enable it. Eventually, NLS will be
6 enabled by default, and you'll need --disable-nls to disable it. You
7 must enable NLS in order to make a GCC distribution.
9 By and large, only diagnostic messages have been internationalized.
10 Some work remains in other areas; for example, GCC does not yet allow
11 non-ASCII letters in identifiers.
13 Not all of GCC's diagnostic messages have been internationalized.
14 Programs like `enquire' and `genattr' are not internationalized, as
15 their users are GCC maintainers who typically need to be able to read
16 English anyway; internationalizing them would thus entail needless
17 work for the human translators. And no one has yet gotten around to
18 internationalizing the messages in the C++ compiler, or in the
19 specialized MIPS-specific programs mips-tdump and mips-tfile.
21 The GCC library should not contain any messages that need
22 internationalization, because it operates below the
23 internationalization library.
25 Currently, the only language translation supplied is en_UK (British English).
27 Unlike some other GNU programs, the GCC sources contain few instances
28 of explicit translation calls like _("string"). Instead, the
29 diagnostic printing routines automatically translate their arguments.
30 For example, GCC source code should not contain calls like `error
31 (_("unterminated comment"))'; it should contain calls like `error
32 ("unterminated comment")' instead, as it is the `error' function's
33 responsibility to translate the message before the user sees it.
35 By convention, any function parameter in the GCC sources whose name
36 ends in `msgid' is expected to be a message requiring translation.
37 For example, the `error' function's first parameter is named `msgid'.
38 GCC's exgettext script uses this convention to determine which
39 function parameter strings need to be translated. The exgettext
40 script also assumes that any occurrence of `%eMSGID}' on a source
41 line, where MSGID does not contain `%' or `}', corresponds to a
42 message MSGID that requires translation; this is needed to identify
43 diagnostics in GCC spec strings.
45 If you enable NLS and modify source files, you'll need to use a
46 special version of the GNU gettext package to propagate the
47 modifications to the translation tables. Apply the following patch
48 (use `patch -p0') to GNU gettext 0.10.35, which you can retrieve from:
50 ftp://alpha.gnu.org/gnu/gettext-0.10.35.tar.gz
52 This patch has been submitted to the GNU gettext maintainer, so
53 eventually we shouldn't need this special gettext version.
55 This patch is free software; you can redistribute it and/or modify
56 it under the terms of the GNU General Public License as published by
57 the Free Software Foundation; either version 2, or (at your option)
60 This patch is distributed in the hope that it will be useful,
61 but WITHOUT ANY WARRANTY; without even the implied warranty of
62 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
63 GNU General Public License for more details.
65 You should have received a copy of the GNU General Public License
66 along with this patch; see the file COPYING. If not, write to
67 the Free Software Foundation, 59 Temple Place - Suite 330,
68 Boston, MA 02111-1307, USA.
70 1998-07-26 Paul Eggert <eggert@twinsun.com>
72 * po/Makefile.in.in (maintainer-clean): Remove cat-id-tbl.c and
75 1998-07-24 Paul Eggert <eggert@twinsun.com>
77 * po/Makefile.in.in (cat-id-tbl.o): Depend on
78 $(top_srcdir)/intl/libgettext.h, not ../intl/libgettext.h.
80 1998-07-20 Paul Eggert <eggert@twinsun.com>
82 * po/Makefile.in.in (.po.pox, all-yes, $(srcdir)/cat-id-tbl.c,
83 $(srcdir)/stamp-cat-id, update-po): Prepend `$(srcdir)/' to
84 files built in the source directory; this is needed for
85 VPATH-based make in Solaris 2.6.
87 1998-07-17 Paul Eggert <eggert@twinsun.com>
89 Add support for user-specified argument numbers for keywords.
90 Extract all strings from a keyword arg, not just the first one.
91 Handle parenthesized commas inside keyword args correctly.
92 Warn about nested keywords.
94 * doc/gettext.texi: Document --keyword=id:argnum.
96 * src/xgettext.c (scan_c_file):
97 Warn about nested keywords, e.g. _(_("xxx")).
98 Warn also about not-yet-implemented but allowed nesting, e.g.
99 dcgettext(..._("xxx")..., "yyy").
100 Get all strings in a keyword arg, not just the first one.
101 Handle parenthesized commas inside keyword args correctly.
103 * src/xget-lex.h (enum xgettext_token_type_ty):
104 Replace xgettext_token_type_keyword1 and
105 xgettext_token_type_keyword2 with just plain
106 xgettext_token_type_keyword; it now has argnum value.
107 Add xgettext_token_type_rp.
108 (struct xgettext_token_ty): Add argnum member.
109 line_number and file_name are now also set for
110 xgettext_token_type_keyword.
111 (xgettext_lex_keyword): Arg is const char *.
113 * src/xget-lex.c: Include "hash.h".
114 (enum token_type_ty): Add token_type_rp.
115 (keywords): Now a hash table.
116 (phase5_get): Return token_type_rp for ')'.
117 (xgettext_lex, xgettext_lex_keyword): Add support for keyword argnums.
118 (xgettext_lex): Return xgettext_token_type_rp for ')'.
119 Report keyword argnum, line number, and file name back to caller.
121 1998-07-09 Paul Eggert <eggert@twinsun.com>
123 * intl/Makefile.in (uninstall):
124 Do nothing unless $(PACKAGE) is gettext.
126 ===================================================================
127 RCS file: doc/gettext.texi,v
128 retrieving revision 0.10.35.0
129 retrieving revision 0.10.35.1
130 diff -pu -r0.10.35.0 -r0.10.35.1
131 --- doc/gettext.texi 1998/05/01 05:53:32 0.10.35.0
132 +++ doc/gettext.texi 1998/07/18 00:25:15 0.10.35.1
133 @@ -1854,13 +1854,19 @@ List of directories searched for input f
134 Join messages with existing file.
137 -@itemx --keyword[=@var{word}]
138 -Additonal keyword to be looked for (without @var{word} means not to
139 +@itemx --keyword[=@var{keywordspec}]
140 +Additonal keyword to be looked for (without @var{keywordspec} means not to
141 use default keywords).
143 -The default keywords, which are always looked for if not explicitly
144 -disabled, are @code{gettext}, @code{dgettext}, @code{dcgettext} and
145 -@code{gettext_noop}.
146 +If @var{keywordspec} is a C identifer @var{id}, @code{xgettext} looks
147 +for strings in the first argument of each call to the function or macro
148 +@var{id}. If @var{keywordspec} is of the form
149 +@samp{@var{id}:@var{argnum}}, @code{xgettext} looks for strings in the
150 +@var{argnum}th argument of the call.
152 +The default keyword specifications, which are always looked for if not
153 +explicitly disabled, are @code{gettext}, @code{dgettext:2},
154 +@code{dcgettext:2} and @code{gettext_noop}.
156 @item -m [@var{string}]
157 @itemx --msgstr-prefix[=@var{string}]
158 ===================================================================
159 RCS file: intl/Makefile.in,v
160 retrieving revision 0.10.35.0
161 retrieving revision 0.10.35.1
162 diff -pu -r0.10.35.0 -r0.10.35.1
163 --- intl/Makefile.in 1998/04/27 21:53:18 0.10.35.0
164 +++ intl/Makefile.in 1998/07/09 21:39:18 0.10.35.1
165 @@ -143,10 +143,14 @@ install-data: all
169 - dists="$(DISTFILES.common)"; \
170 - for file in $$dists; do \
171 - rm -f $(gettextsrcdir)/$$file; \
173 + if test "$(PACKAGE)" = "gettext"; then \
174 + dists="$(DISTFILES.common)"; \
175 + for file in $$dists; do \
176 + rm -f $(gettextsrcdir)/$$file; \
184 ===================================================================
185 RCS file: src/xget-lex.c,v
186 retrieving revision 0.10.35.0
187 retrieving revision 0.10.35.1
188 diff -pu -r0.10.35.0 -r0.10.35.1
189 --- src/xget-lex.c 1998/07/09 22:49:48 0.10.35.0
190 +++ src/xget-lex.c 1998/07/18 00:25:15 0.10.35.1
194 #include "libgettext.h"
196 #include "str-list.h"
197 #include "xget-lex.h"
199 @@ -83,6 +84,7 @@ enum token_type_ty
207 @@ -109,7 +111,7 @@ static FILE *fp;
208 static int trigraphs;
209 static int cplusplus_comments;
210 static string_list_ty *comment;
211 -static string_list_ty *keywords;
212 +static hash_table keywords;
213 static int default_keywords = 1;
215 /* These are for tracking whether comments count as immediately before
216 @@ -941,6 +943,10 @@ phase5_get (tp)
217 tp->type = token_type_lp;
221 + tp->type = token_type_rp;
225 tp->type = token_type_comma;
227 @@ -1179,6 +1185,7 @@ xgettext_lex (tp)
231 + void *keyword_value;
235 @@ -1213,17 +1220,20 @@ xgettext_lex (tp)
236 if (default_keywords)
238 xgettext_lex_keyword ("gettext");
239 - xgettext_lex_keyword ("dgettext");
240 - xgettext_lex_keyword ("dcgettext");
241 + xgettext_lex_keyword ("dgettext:2");
242 + xgettext_lex_keyword ("dcgettext:2");
243 xgettext_lex_keyword ("gettext_noop");
244 default_keywords = 0;
247 - if (string_list_member (keywords, token.string))
249 - tp->type = (strcmp (token.string, "dgettext") == 0
250 - || strcmp (token.string, "dcgettext") == 0)
251 - ? xgettext_token_type_keyword2 : xgettext_token_type_keyword1;
252 + if (find_entry (&keywords, token.string, strlen (token.string),
256 + tp->type = xgettext_token_type_keyword;
257 + tp->argnum = (int) keyword_value;
258 + tp->line_number = token.line_number;
259 + tp->file_name = logical_file_name;
262 tp->type = xgettext_token_type_symbol;
263 @@ -1236,6 +1246,12 @@ xgettext_lex (tp)
264 tp->type = xgettext_token_type_lp;
267 + case token_type_rp:
268 + last_non_comment_line = newline_count;
270 + tp->type = xgettext_token_type_rp;
273 case token_type_comma:
274 last_non_comment_line = newline_count;
276 @@ -1263,16 +1279,32 @@ xgettext_lex (tp)
279 xgettext_lex_keyword (name)
284 default_keywords = 0;
287 - if (keywords == NULL)
288 - keywords = string_list_alloc ();
293 + if (keywords.table == NULL)
294 + init_hash (&keywords, 100);
296 + sp = strchr (name, ':');
300 + argnum = atoi (sp + 1);
304 + len = strlen (name);
308 - string_list_append_unique (keywords, name);
309 + insert_entry (&keywords, name, len, (void *) argnum);
313 ===================================================================
314 RCS file: src/xget-lex.h,v
315 retrieving revision 0.10.35.0
316 retrieving revision 0.10.35.1
317 diff -pu -r0.10.35.0 -r0.10.35.1
318 --- src/xget-lex.h 1998/07/09 22:49:48 0.10.35.0
319 +++ src/xget-lex.h 1998/07/18 00:25:15 0.10.35.1
320 @@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suit
321 enum xgettext_token_type_ty
323 xgettext_token_type_eof,
324 - xgettext_token_type_keyword1,
325 - xgettext_token_type_keyword2,
326 + xgettext_token_type_keyword,
327 xgettext_token_type_lp,
328 + xgettext_token_type_rp,
329 xgettext_token_type_comma,
330 xgettext_token_type_string_literal,
331 xgettext_token_type_symbol
332 @@ -37,8 +37,14 @@ struct xgettext_token_ty
334 xgettext_token_type_ty type;
336 - /* These 3 are only set for xgettext_token_type_string_literal. */
337 + /* This 1 is set only for xgettext_token_type_keyword. */
340 + /* This 1 is set only for xgettext_token_type_string_literal. */
343 + /* These 2 are set only for xgettext_token_type_keyword and
344 + xgettext_token_type_string_literal. */
348 @@ -50,7 +56,7 @@ void xgettext_lex PARAMS ((xgettext_toke
349 const char *xgettext_lex_comment PARAMS ((size_t __n));
350 void xgettext_lex_comment_reset PARAMS ((void));
351 /* void xgettext_lex_filepos PARAMS ((char **, int *)); FIXME needed? */
352 -void xgettext_lex_keyword PARAMS ((char *__name));
353 +void xgettext_lex_keyword PARAMS ((const char *__name));
354 void xgettext_lex_cplusplus PARAMS ((void));
355 void xgettext_lex_trigraphs PARAMS ((void));
357 ===================================================================
358 RCS file: src/xgettext.c,v
359 retrieving revision 0.10.35.0
360 retrieving revision 0.10.35.1
361 diff -pu -r0.10.35.0 -r0.10.35.1
362 --- src/xgettext.c 1998/07/09 22:49:48 0.10.35.0
363 +++ src/xgettext.c 1998/07/18 00:25:15 0.10.35.1
364 @@ -835,6 +835,8 @@ scan_c_file(filename, mlp, is_cpp_file)
368 + int commas_to_skip; /* defined only when in states 1 and 2 */
369 + int paren_nesting; /* defined only when in state 2 */
371 /* Inform scanner whether we have C++ files or not. */
373 @@ -854,63 +856,79 @@ scan_c_file(filename, mlp, is_cpp_file)
375 xgettext_token_ty token;
377 - /* A simple state machine is used to do the recognising:
378 + /* A state machine is used to do the recognising:
379 State 0 = waiting for something to happen
380 - State 1 = seen one of our keywords with string in first parameter
381 - State 2 = was in state 1 and now saw a left paren
382 - State 3 = seen one of our keywords with string in second parameter
383 - State 4 = was in state 3 and now saw a left paren
384 - State 5 = waiting for comma after being in state 4
385 - State 6 = saw comma after being in state 5 */
386 + State 1 = seen one of our keywords
387 + State 2 = waiting for part of an argument */
388 xgettext_lex (&token);
391 - case xgettext_token_type_keyword1:
392 + case xgettext_token_type_keyword:
393 + if (!extract_all && state == 2)
395 + if (commas_to_skip == 0)
398 + _("%s:%d: warning: keyword nested in keyword arg"),
399 + token.file_name, token.line_number);
403 + /* Here we should nest properly, but this would require a
404 + potentially unbounded stack. We haven't run across an
405 + example that needs this functionality yet. For now,
406 + we punt and forget the outer keyword. */
408 + _("%s:%d: warning: keyword between outer keyword and its arg"),
409 + token.file_name, token.line_number);
411 + commas_to_skip = token.argnum - 1;
415 - case xgettext_token_type_keyword2:
419 case xgettext_token_type_lp:
436 + case xgettext_token_type_rp:
437 + if (state == 2 && paren_nesting != 0)
443 case xgettext_token_type_comma:
444 - state = state == 5 ? 6 : 0;
445 + if (state == 2 && commas_to_skip != 0)
446 + commas_to_skip -= paren_nesting == 0;
451 case xgettext_token_type_string_literal:
452 - if (extract_all || state == 2 || state == 6)
454 - remember_a_message (mlp, &token);
457 + if (extract_all || (state == 2 && commas_to_skip == 0))
458 + remember_a_message (mlp, &token);
462 - state = (state == 4 || state == 5) ? 5 : 0;
463 + state = state == 2 ? 2 : 0;
467 case xgettext_token_type_symbol:
468 - state = (state == 4 || state == 5) ? 5 : 0;
469 + state = state == 2 ? 2 : 0;
477 case xgettext_token_type_eof:
479 ===================================================================
480 RCS file: po/Makefile.in.in,v
481 retrieving revision 0.10.35.0
482 retrieving revision 0.10.35.5
483 diff -u -r0.10.35.0 -r0.10.35.5
484 --- po/Makefile.in.in 1998/07/20 20:20:38 0.10.35.0
485 +++ po/Makefile.in.in 1998/07/26 09:07:52 0.10.35.5
490 - $(MAKE) $(PACKAGE).pot
491 + $(MAKE) $(srcdir)/$(PACKAGE).pot
492 $(MSGMERGE) $< $(srcdir)/$(PACKAGE).pot -o $*.pox
499 -all-yes: cat-id-tbl.c $(CATALOGS)
500 +all-yes: $(srcdir)/cat-id-tbl.c $(CATALOGS)
503 $(srcdir)/$(PACKAGE).pot: $(POTFILES)
505 || ( rm -f $(srcdir)/$(PACKAGE).pot \
506 && mv $(PACKAGE).po $(srcdir)/$(PACKAGE).pot )
508 -$(srcdir)/cat-id-tbl.c: stamp-cat-id; @:
509 -$(srcdir)/stamp-cat-id: $(PACKAGE).pot
510 +$(srcdir)/cat-id-tbl.c: $(srcdir)/stamp-cat-id; @:
511 +$(srcdir)/stamp-cat-id: $(srcdir)/$(PACKAGE).pot
513 sed -f ../intl/po2tbl.sed $(srcdir)/$(PACKAGE).pot \
514 | sed -e "s/@PACKAGE NAME@/$(PACKAGE)/" > cat-id-tbl.tmp
519 -cat-id-tbl.o: ../intl/libgettext.h
520 +cat-id-tbl.o: $(srcdir)/cat-id-tbl.c $(top_srcdir)/intl/libgettext.h
521 + $(COMPILE) $(srcdir)/cat-id-tbl.c
523 dvi info tags TAGS ID:
526 maintainer-clean: distclean
527 @echo "This command is intended for maintainers to use;"
528 @echo "it deletes files that may require special tools to rebuild."
530 + rm -f $(GMOFILES) cat-id-tbl.c stamp-cat-id
532 distdir = ../$(PACKAGE)-$(VERSION)/$(subdir)
533 dist distdir: update-po $(DISTFILES)
538 - $(MAKE) $(PACKAGE).pot
539 + $(MAKE) $(srcdir)/$(PACKAGE).pot
540 PATH=`pwd`/../src:$$PATH; \
542 catalogs='$(CATALOGS)'; \