Subject: Re: [bug#35394] [PATCH 4/4 v4] Grub i18n

From: Ludovic Courtès <[email-masked]>
Date: Mon, 19 Oct 2020 15:21:16 +0200

Hi,

Miguel Ángel Arruga Vivas <[email-masked]> skribis:

>> (Brainstorm…)
>>
>> I would simply translate it on the client side by temporarily setting
>> LANGUAGE to the target locale.  The downside is that this will not be
>> translated if the target locale is not supported by the host.
>>
>> Alternately, we could have:
>>
>>   (define (formatted-i18n-string locale fmt . args)
>>     (computed-file "formatted-i18n-string"
>>                    #~(begin
>>                        (textdomain …)
>>                        (setlocale …)
>>                        (call-with-output-file #$output
>>                          (lambda (port)
>>                            (format port …))))))
>
> I'd prefer this option, as it avoids triggering the translation on the
> client side, and it could be used in other places too if needed.  It
> needs xgettext support and a tag (like F_ or L_) would be very concise,
> and useful from my point of view.

That’s OK, we can do (as we did in other places) something like:

  (define-syntax formatted-i18n-string
    (syntax-rules (G_ N_)
      ((_ locale (G_ fmt) args ...)
       (%formatted-i18n-string locale fmt args ...))
      …))

That way, xgettext is happy.

> There are some other places (e.g. gnu/machine/ssh.scm:395) which use
> string-append for user visible strings[1].  They should be localized
> with a proper format, and including the format call into the i18n call
> itself helps to ensure that.

Yup!

>> We would then need to adjust all bootloaders to read the label from that
>> file.  If the user-supplied ‘label’ is a plain string, we’d wrap it in
>> (plain-file …) so that ‘label’ is always a file-like object.
>
> I'll probably raise some questions about the design here and there, and
> maybe open another thread for the point before, but as soon as I have
> anything tangible, I'll send a patch. :-)

Sure!

We may end up delaying that post-release if there’s potential for
breakage.  We’ll see.

Thanks!

Ludo’.