]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ABOUT-GCC-NLS: add usage guidance
authorJason Merrill <jason@redhat.com>
Thu, 19 Oct 2023 15:07:18 +0000 (11:07 -0400)
committerJason Merrill <jason@redhat.com>
Thu, 19 Oct 2023 16:34:35 +0000 (12:34 -0400)
gcc/ChangeLog:

* ABOUT-GCC-NLS: Add usage guidance.

gcc/ABOUT-GCC-NLS

index e90a67144e34e94fe1dbc489bc2c23ee0d5217dc..9424de42e1509726faa9b0e0c1d74e4a2e654da4 100644 (file)
@@ -23,6 +23,22 @@ For example, GCC source code should not contain calls like `error
 ("unterminated comment")' instead, as it is the `error' function's
 responsibility to translate the message before the user sees it.
 
+In general, use no markup for strings that are the immediate format string
+argument of a diagnostic function.  Use G_("str") for strings that will be
+used as the format string for a diagnostic but are e.g. assigned to a
+variable first.  Use N_("str") for strings that are not diagnostic format
+strings, but will still be translated later.  Use _("str") for strings that
+will not be translated elsewhere.  It's important not to use _("str") in
+the initializer of a statically allocated variable; use one of the others
+instead and make sure that uses of that variable translate the string,
+whether directly with _(msg) or by passing it to a diagnostic or other
+function that performs the translation.
+
+Avoid using %s to compose a diagnostic message from multiple translatable
+strings; instead, write out the full diagnostic message for each variant.
+Only use %s for message components that do not need translation, such as
+keywords.
+
 By convention, any function parameter in the GCC sources whose name
 ends in `msgid' is expected to be a message requiring translation.
 If the parameter name ends with `gmsgid', it is assumed to be a GCC