This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH][aarch64] Fix error calls in aarch64 code so they can be tranlated


On 09/19/2017 09:54 AM, Steve Ellcey wrote:
On Tue, 2017-09-19 at 09:50 +0200, Frédéric Marchal wrote:
On lundi 18 septembre 2017 13 h 20 min 25 s CEST Martin Sebor wrote:

I haven't looked at all of them but from the few I have seen it
seems that rephrasing the messages along the following lines would
be a way to get around the translation issue and without increasing
the number of calls (though not without the conditional):

   error (is_pragma
          ? G_("missing name in %<#pragma target\(\"%s=\")%>")
          : G_("missing name in %<target(\"%s=\")%> attribute"),
          "arch");

The additional benefit of this approach is that it would also make
the quoting consistent with what seems to be the prevailing style
of these sorts of messages.  (It would be nice to eventually
converge on the same style/quoting and phrasing across all back
and front ends.)
Indeed! That's even better as the message uses words the user sees in the
source code whatever his/her locale language is.

With your proposal, I know I must not translate "target" because it clearly is
part of the programming language. With the former message, I would have
translated "target" as part of the human language message. Your approach is
clearly better.

Frederic

Are '%<...%>' described somewhere?  These aren't normal printf options
are they?  I don't think I have ever used them before.  I am also not
sure why you have '%s=' means vs. '%s'.  Is it even worth breaking the
word 'arch' out of the string vs. having something like:

	error (is_pragma
		? G_("missing name in %<#pragma target \"arch\"%>)
		: G_("missing name in %<target arch%> attribute"));

%< and %> are (briefly) mentioned in pretty-print.c, just above
pp_format.  They should be used in preference to the apostrophe
to introduce quoting and color highlighting in diagnostics.
(There's also logic in the pretty printer to help detect
mismatches between these and other related directives, but none
for the apostrophe.)

I used %s= because it appears with some consistency in other
similar messages in gcc.pot, e.g.:

  %<generic%> CPU can be used only for %<target(\"tune=\")%> attribute"

(I ran 'grep target gcc.pot | grep attr' to find them, along with
some of the inconsistencies among them.)

It doesn't look to me like parameterizing the message on the name
of the target attribute reduces the number of messages that need
to be translated so it doesn't gain much (if anything) here.  It
does have help in a few other places where I've been working
recently that deal with attributes and I used mostly out of habit.

Martin


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]