]>
Commit | Line | Data |
---|---|---|
d70283ce JL |
1 | Notes on GCC's Native Language Support |
2 | ||
d70283ce JL |
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 | ||
842eb2a3 | 7 | Not all of GCC's diagnostic messages have been internationalized. Programs |
bfb53001 ZW |
8 | like `genattr' (in fact all gen* programs) are not internationalized, as |
9 | their users are GCC maintainers who typically need to be able to read | |
10 | English anyway; internationalizing them would thus entail needless work for | |
11 | the human translators. Messages used for debugging, such as used in dumped | |
12 | tables, should also not be translated. | |
d70283ce JL |
13 | |
14 | The GCC library should not contain any messages that need | |
842eb2a3 PT |
15 | internationalization, because it operates below the internationalization |
16 | library. | |
d70283ce | 17 | |
d70283ce JL |
18 | Unlike some other GNU programs, the GCC sources contain few instances |
19 | of explicit translation calls like _("string"). Instead, the | |
20 | diagnostic printing routines automatically translate their arguments. | |
21 | For example, GCC source code should not contain calls like `error | |
22 | (_("unterminated comment"))'; it should contain calls like `error | |
23 | ("unterminated comment")' instead, as it is the `error' function's | |
24 | responsibility to translate the message before the user sees it. | |
25 | ||
00e7c49f JM |
26 | In general, use no markup for strings that are the immediate format string |
27 | argument of a diagnostic function. Use G_("str") for strings that will be | |
28 | used as the format string for a diagnostic but are e.g. assigned to a | |
29 | variable first. Use N_("str") for strings that are not diagnostic format | |
30 | strings, but will still be translated later. Use _("str") for strings that | |
31 | will not be translated elsewhere. It's important not to use _("str") in | |
32 | the initializer of a statically allocated variable; use one of the others | |
33 | instead and make sure that uses of that variable translate the string, | |
34 | whether directly with _(msg) or by passing it to a diagnostic or other | |
35 | function that performs the translation. | |
36 | ||
37 | Avoid using %s to compose a diagnostic message from multiple translatable | |
38 | strings; instead, write out the full diagnostic message for each variant. | |
39 | Only use %s for message components that do not need translation, such as | |
40 | keywords. | |
41 | ||
d70283ce JL |
42 | By convention, any function parameter in the GCC sources whose name |
43 | ends in `msgid' is expected to be a message requiring translation. | |
4b794eaf JJ |
44 | If the parameter name ends with `gmsgid', it is assumed to be a GCC |
45 | diagnostics format string requiring translation, if it ends with | |
46 | `cmsgid', it is assumed to be a format string for `printf' family | |
47 | of functions, requiring a translation. | |
48 | For example, the `error' function's first parameter is named `gmsgid'. | |
d70283ce JL |
49 | GCC's exgettext script uses this convention to determine which |
50 | function parameter strings need to be translated. The exgettext | |
51 | script also assumes that any occurrence of `%eMSGID}' on a source | |
52 | line, where MSGID does not contain `%' or `}', corresponds to a | |
53 | message MSGID that requires translation; this is needed to identify | |
54 | diagnostics in GCC spec strings. | |
4b794eaf JJ |
55 | The `G_(GMSGID)' macro defined in intl.h can be used to mark GCC diagnostics |
56 | format strings as requiring translation, but other than that it is a | |
57 | no-op at runtime. | |
d70283ce | 58 | |
4b794eaf | 59 | If you modify source files, you'll need at least version 0.14.15 of the |
a71d3613 PT |
60 | GNU gettext package to propagate the modifications to the translation |
61 | tables. | |
842eb2a3 | 62 | |
a71d3613 PT |
63 | After having built and installed these gettext tools, you have to |
64 | configure GCC with --enable-maintainer-mode to get the master catalog | |
65 | rebuilt. | |
ad41bd84 JM |
66 | |
67 | \f | |
a945c346 | 68 | Copyright (C) 1998-2024 Free Software Foundation, Inc. |
ad41bd84 JM |
69 | |
70 | Copying and distribution of this file, with or without modification, | |
71 | are permitted in any medium without royalty provided the copyright | |
72 | notice and this notice are preserved. |