unofficial mirror of guix-patches@gnu.org 
 help / color / mirror / code / Atom feed
From: "Miguel Ángel Arruga Vivas" <rosen644835@gmail.com>
To: "Ludovic Courtès" <ludo@gnu.org>
Cc: 35394@debbugs.gnu.org
Subject: [bug#35394] [PATCH 4/4 v4] Grub i18n
Date: Mon, 19 Oct 2020 13:41:36 +0200	[thread overview]
Message-ID: <878sc2phn3.fsf@gmail.com> (raw)
In-Reply-To: <87o8ky1tx6.fsf@gnu.org> ("Ludovic Courtès"'s message of "Mon, 19 Oct 2020 10:50:13 +0200")

Hi Ludo,

Thanks for your review and your ideas, I'll comment inline.

Ludovic Courtès <ludo@gnu.org> writes:
>> +  (define (translate-label label)
>> +    (match label
>> +      (('hurd name version)
>> +       ;; TRANSLATORS: The first parameter is the capitalized package name
>> +       ;; for the Hurd kernel, which uses the definite article in English.
>> +       ;; The second parameter contains the version string.
>> +       #~(format #f (G_ "GNU with the ~a ~a") package version))
>> +      (('linux name version)
>> +       ;; TRANSLATORS: The first parameter is the capitalized package name
>> +       ;; for Linux kernel, which doesn't use the definite article in
>> +       ;; English.  The second parameter contains the version string.
>> +       #~(format #f (G_ "GNU with ~a ~a") package version))
>> +      (('unknown)
>> +       ;; TRANSLATORS: This is the label for an unknown system to be booted.
>> +       #~(G_ "GNU"))
>> +      ((? string? old-format)
>> +       ;; We cannot translate properly the old format.
>> +       old-format)))
>
> It’s not good that we’re baking assumptions about the label here: the
> user is free to choose the label they want in the ‘label’ field, and we
> don’t want to replicate “GNU with the” etc. in each bootloader.

I guess the main problem here was calling it 'old-format', as this is
the format that would be received for the labels provided by the user
too, I should have called it 'fixed-label' instead.  I didn't though of
this at first so that was the name, but the user provided label works as
always: the installation image was the first example I checked, as it
does exactly that---that startled me a bit until I noticed, by the way.

> It’s also not great that we’re changing the boot parameters again as
> this can make compatibility trickier down the road.

That was an important point of this design, and the reason why I created
the test in the first place: the tests try to cover all the
possibilities, the old format and the new one(s). :-)

> (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.  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.

> 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. :-)

Happy hacking!
Miguel

[1] https://www.gnu.org/software/gettext/manual/gettext.html#No-string-concatenation




  reply	other threads:[~2020-10-19 11:43 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-04-23 13:17 [bug#35394] [PATCH 0/3] Bootloader localization Miguel
2019-04-23 13:26 ` [bug#35394] [PATCH 1/3] system: Add locale to boot-parameters Miguel
2019-04-23 13:26 ` [bug#35394] [PATCH 2/3] system: Provide locale information to the bootloader Miguel
2019-04-23 13:26 ` [bug#35394] [PATCH 3/3] system: Use locale information in grub.cfg Miguel
2019-04-26 10:50 ` [bug#35394] [PATCH 3/4] gnu: grub: Add locale output for bootloading Miguel
2019-05-03 12:27   ` Miguel
2019-04-26 10:51 ` [bug#35394] [PATCH 4/4] system: Use locale information in grub.cfg Miguel
2019-05-03 12:27   ` Miguel
2019-04-29  7:56 ` [bug#35394] [PATCH 0/3] Bootloader localization Ludovic Courtès
     [not found]   ` <20191021124035.531bed75@gmail.com>
2019-10-21 10:46     ` [bug#35394] [PATCH 1/3] system: Add locale to boot-parameters Miguel Arruga Vivas
2019-10-21 10:46     ` [bug#35394] [PATCH 2/3] system: Provide locale information to the bootloader Miguel Arruga Vivas
2019-10-21 10:46     ` [bug#35394] [PATCH 3/3] system: Use locale information in grub.cfg Miguel Arruga Vivas
2020-10-11 14:18 ` [bug#35394] [PATCH 1/1 v4] Grub i18n Miguel Ángel Arruga Vivas
2020-10-17 16:32   ` Ludovic Courtès
2020-10-18 15:09     ` [bug#35394] [PATCH 4/4 " Miguel Ángel Arruga Vivas
2020-10-18 15:43       ` Miguel Ángel Arruga Vivas
2020-10-19  8:50         ` Ludovic Courtès
2020-10-19 11:41           ` Miguel Ángel Arruga Vivas [this message]
2020-10-19 13:21             ` Ludovic Courtès
2020-10-19 13:44               ` Miguel Ángel Arruga Vivas
2020-10-20 20:50                 ` Ludovic Courtès
2020-10-20 21:19                   ` bug#35394: " Miguel Ángel Arruga Vivas

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://guix.gnu.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=878sc2phn3.fsf@gmail.com \
    --to=rosen644835@gmail.com \
    --cc=35394@debbugs.gnu.org \
    --cc=ludo@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/guix.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).