guix-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[bug#35790] [PATCH] scripts: lint: Handle warnings with a record type.


From: Ludovic Courtès
Subject: [bug#35790] [PATCH] scripts: lint: Handle warnings with a record type.
Date: Fri, 07 Jun 2019 09:38:05 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/26.2 (gnu/linux)

Hello,

Christopher Baines <address@hidden> skribis:

> Ludovic Courtès <address@hidden> writes:

[...]

>>> +(define* (make-warning package message
>>> +                       #:key field location)
>>> +  (make-lint-warning
>>> +   package
>>> +   message
>>
>> In practice MESSAGE is already translated.  I think it would be more
>> flexible if it were not; ‘lint-warning-message’ would always return the
>> English message, and it’d be up to the user to call ‘gettext’ on it,
>> like we do for package descriptions.
>>
>> To achieve this, you’d need a little trick so that ‘xgettext’ can still
>> extract the messages, like:
>>
>>
>>   (define-syntax-rule make-warning
>>     (syntax-rule (G_)
>>       ((_ package (G_ message) rest ...)
>>        (%make-warning package message rest ...))))
>>
>> where ‘%make-warning’ is the procedure you define above.
>>
>> Then you need an explicit call to ‘G_’ at the point where messages are
>> displayed.
>>
>> Does that make sense?
>
> Yes, but I'm unsure it'll work for all the messages.
>
> Some of them it translates a format string first, then uses that format
> string, and that becomes the message, e.g.
>
>   (format #f (G_ "invalid description: ~s") description)
>
> Given that you'd be trying to get the translation for "invalid
> description: guile" for example, I'm not sure you can defer the
> translation without also defering customising the message, if that makes
> sense?

Good point!

A possibility would be to pass ‘make-warning’ a ‘format’ list instead of
a single string:

  (make-warning package (list (G_ "~a is bad") 'something) …)

That’d solve the problem but it’d have to be packaged nicely to avoid
having too much boilerplate.

WDYT?

Thanks,
Ludo’.





reply via email to

[Prev in Thread] Current Thread [Next in Thread]