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

Hi!

Miguel Ángel Arruga Vivas <rosen644835@gmail.com> skribis:

> From e9f3c255c13abc14e1f0decf5460b7a2f9a2d162 Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Miguel=20=C3=81ngel=20Arruga=20Vivas?=
>  <rosen644835@gmail.com>
> Date: Sat, 17 Oct 2020 21:27:51 +0200
> Subject: [PATCH] system: nls for boot labels.
>
> * gnu/bootloader/extlinux.scm (extlinux-configuration-file): Add
> keyword locale.
> [translate-label]: New function that formats the label after
> translation.
> [menu-entry->gexp]: Use translate-label.
> [init-gettext]: Init gettext with the language provided through the
> configuration.
> [builder]: Use init-gettext, define G_ and translate strings.
> * gnu/bootloader/grub.scm (eye-candy): Translate string.
> (grub-configuration-file)[translate-label]: New function.
> [menu-entry->gexp]: Use translate-label.
> [init-gettext]: New g-exp variable.
> [locale-config]: Translate string.
> [builder]: Use init-gettext, define G_ and translate strings.
> * gnu/system.scm (kernel->boot-label): Modify return type, and
> document it, to allow correct translation of the labels.
> * po/guix/POTFILES.in: Add gnu/bootloader/grub.scm.
> * tests/boot-parameters.scm (%default-label): Update to the new
> format.
> (%old-label): Renamed from old %default-label.
> (read old format): New test case.

[...]

>  (define* (extlinux-configuration-file config entries
>                                        #:key
> +                                      (locale #f)
>                                        (system (%current-system))
>                                        (old-entries '())
>                                        #:allow-other-keys)
> @@ -38,8 +43,38 @@ corresponding to old generations of the system."
>    (define all-entries
>      (append entries (bootloader-configuration-menu-entries config)))
>  
> +  (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.

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

(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 …))))))

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.

WDYT?

Thanks,
Ludo’.




  reply	other threads:[~2020-10-19  8:52 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 [this message]
2020-10-19 11:41           ` Miguel Ángel Arruga Vivas
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=87o8ky1tx6.fsf@gnu.org \
    --to=ludo@gnu.org \
    --cc=35394@debbugs.gnu.org \
    --cc=rosen644835@gmail.com \
    /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).