GNU bug report logs - #65424
Guix doesn't use positional arguments in translated formatted messages

Previous Next

Package: guix;

Reported by: Maxime Devos <maximedevos <at> telenet.be>

Date: Mon, 21 Aug 2023 12:10:02 UTC

Severity: normal

To reply to this bug, email your comments to 65424 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-guix <at> gnu.org:
bug#65424; Package guix. (Mon, 21 Aug 2023 12:10:02 GMT) Full text and rfc822 format available.

Acknowledgement sent to Maxime Devos <maximedevos <at> telenet.be>:
New bug report received and forwarded. Copy sent to bug-guix <at> gnu.org. (Mon, 21 Aug 2023 12:10:02 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: bug-guix <bug-guix <at> gnu.org>
Subject: Guix doesn't use positional arguments in translated formatted messages
Date: Mon, 21 Aug 2023 14:09:14 +0200
[Message part 1 (text/plain, inline)]
Consider, e.g.,

(format #t (G_ "~0@*~a should be set to ~1@*~a instead of ~2@*~a~%") 
"CC" "(cc-for-target)" "gcc")
->
CC should be set to (cc-for-target) instead of gcc

By using positional arguments like this, translators can reorder the 
sentence to:

(format #t (G_ "It's not ~2@*~a that ~0@*~a should be set to, but 
~1@*~a~%") "CC" (cc-for-target) "gcc"))

~0@*~a should be set to ~1@*~a instead of ~2@*~a~%") "CC" 
"(cc-for-target)" "gcc")
->
It's not gcc that CC should be set to, but (cc-for-target).

CC should be set to (cc-for-target) instead of gcc

Such reorderings are occasionally useful, yet AFAIK nowhere (except 
po/guix/ta.po, the mcron service and de.po) is this used.

Sure, you could as translator add these ~N@* afterwards, but you need to 
know that's possible in the first place (and if you know it's possible, 
you still need to remember or rediscover what exactly to write), and it 
would be much simpler and more discoverable if they were included from 
the start.  Also, IIRC, Weblate complains if you add these.

p.s.: I'm writing a new linter, this particular example doesn't occur 
yet in Guix.
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Information forwarded to bug-guix <at> gnu.org:
bug#65424; Package guix. (Mon, 21 Aug 2023 14:21:02 GMT) Full text and rfc822 format available.

Message #8 received at 65424 <at> debbugs.gnu.org (full text, mbox):

From: Julien Lepiller <julien <at> lepiller.eu>
To: Maxime Devos <maximedevos <at> telenet.be>, 65424 <at> debbugs.gnu.org
Subject: Re: bug#65424: Guix doesn't use positional arguments in translated formatted messages
Date: Mon, 21 Aug 2023 16:20:32 +0200
Le 21 août 2023 14:09:14 GMT+02:00, Maxime Devos <maximedevos <at> telenet.be> a écrit :
>Consider, e.g.,
>
>(format #t (G_ "~0@*~a should be set to ~1@*~a instead of ~2@*~a~%") "CC" "(cc-for-target)" "gcc")
>->
>CC should be set to (cc-for-target) instead of gcc
>
>By using positional arguments like this, translators can reorder the sentence to:
>
>(format #t (G_ "It's not ~2@*~a that ~0@*~a should be set to, but ~1@*~a~%") "CC" (cc-for-target) "gcc"))
>
>~0@*~a should be set to ~1@*~a instead of ~2@*~a~%") "CC" "(cc-for-target)" "gcc")
>->
>It's not gcc that CC should be set to, but (cc-for-target).
>
>CC should be set to (cc-for-target) instead of gcc
>
>Such reorderings are occasionally useful, yet AFAIK nowhere (except po/guix/ta.po, the mcron service and de.po) is this used.
>
>Sure, you could as translator add these ~N@* afterwards, but you need to know that's possible in the first place (and if you know it's possible, you still need to remember or rediscover what exactly to write), and it would be much simpler and more discoverable if they were included from the start.  Also, IIRC, Weblate complains if you add these.
>
>p.s.: I'm writing a new linter, this particular example doesn't occur yet in Guix.

That sounds reasonnabe. The very least we could do is document this syntax in the manual. Weblate would complain indeed, sirce it won't find the same formats in the source and target strings. It might complain about the order too, but that's something we could contribute upstseam if it happens.




Information forwarded to bug-guix <at> gnu.org:
bug#65424; Package guix. (Mon, 21 Aug 2023 14:46:03 GMT) Full text and rfc822 format available.

Message #11 received at 65424 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Julien Lepiller <julien <at> lepiller.eu>, 65424 <at> debbugs.gnu.org
Subject: Re: bug#65424: Guix doesn't use positional arguments in translated
 formatted messages
Date: Mon, 21 Aug 2023 16:45:46 +0200
[Message part 1 (text/plain, inline)]

Op 21-08-2023 om 16:20 schreef Julien Lepiller:
> Le 21 août 2023 14:09:14 GMT+02:00, Maxime Devos <maximedevos <at> telenet.be> a écrit :
>> Consider, e.g.,
>>
>> (format #t (G_ "~0@*~a should be set to ~1@*~a instead of ~2@*~a~%") "CC" "(cc-for-target)" "gcc")
>> ->
>> CC should be set to (cc-for-target) instead of gcc
>>
>> By using positional arguments like this, translators can reorder the sentence to:
>>
>> (format #t (G_ "It's not ~2@*~a that ~0@*~a should be set to, but ~1@*~a~%") "CC" (cc-for-target) "gcc"))
>>
>> ~0@*~a should be set to ~1@*~a instead of ~2@*~a~%") "CC" "(cc-for-target)" "gcc")
>> ->
>> It's not gcc that CC should be set to, but (cc-for-target).
>>
>> CC should be set to (cc-for-target) instead of gcc
>>
>> Such reorderings are occasionally useful, yet AFAIK nowhere (except po/guix/ta.po, the mcron service and de.po) is this used.
>>
>> Sure, you could as translator add these ~N@* afterwards, but you need to know that's possible in the first place (and if you know it's possible, you still need to remember or rediscover what exactly to write), and it would be much simpler and more discoverable if they were included from the start.  Also, IIRC, Weblate complains if you add these.
>>
>> p.s.: I'm writing a new linter, this particular example doesn't occur yet in Guix.
> 
> That sounds reasonnabe. The very least we could do is document this syntax in the manual. Weblate would complain indeed, sirce it won't find the same formats in the source and target strings. It might complain about the order too, but that's something we could contribute upstseam if it happens.


Proposed new documentation:

* 22.5.5 Translatable messages

When constructing translatable messages with 'format' (<reference to 
guile manual>), it is important to use positional arguments.  For 
example, instead of writing

  (format #t (G_ "The package '~a' is newer than '~a'.~%")
             '("foo" "bar")),

you should write

  (format #t (G_ "The package '~1@*~a' is newer than '~2@*~a'.~%")
             '("foo" "bar"))

instead.  The reason for this is that when translating between 
languages, the word order sometimes changes.  While a translator could 
manually add the '~N@*' to the translation, it is more straightforward 
to include it in the untranslated message from the beginning.

There is also a technical reason for this: Weblate doesn't cope well 
with the translated message and original message having a different 
number of '~'.

Update the following documentation:

     If there are multiple formatting symbols, make sure to respect the
     order.  Guile does not know in which order you intended the string
     to be read, so it will substitute the symbols in the same order as
     the English sentence.

     As an example, you cannot translate ‘package '~a' has been
     superseded by '~a'’ by ‘'~a' superseeds package '~a'’, because the
     meaning would be reversed.  If FOO is superseded by BAR, the
     translation would read ‘'foo' superseeds package 'bar'’.  To work
     around this problem, it is possible to use more advanced formatting
     to select a given piece of data, instead of following the default
     English order.  *Note (guile)Formatted Output::, for more
     information on formatting in Guile.

--->

     If there are multiple formatting symbols, and positional arguments
     are used, you should be able to reorder the formatting symbols if
     it makes more sense in your language.  The positional information
     tells Guile which formatting symbol needs to be replaced by which
     value.

     If positional arguments aren't used and there are multiple
     formatting symbols, that's a bug, and possibly to translate
     the message properly you may need to report the bug.  The use of
     positional arguments in Guix is fairly new, so you might need
     to report plenty of them!

     As an example, you can translate ‘package '~1@*~a' has been
     superseded by '~2@*~a'’ by ‘'~2@*~a' superseeds package '~1@*~a'’.
     In this example, you recognise the positional arguments by the
     prefixes '~1@*' and '~2@*'.

(To be explicit, the changes are Copyright 2023 Maxime Devos

Permission is granted to copy, distribute and/or modify this document
under the terms of the GNU Free Documentation License, Version 1.3 or
any later version published by the Free Software Foundation; with no
Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.  A
copy of the license is included in the section entitled ``GNU Free
Documentation License''.)
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

Information forwarded to bug-guix <at> gnu.org:
bug#65424; Package guix. (Mon, 21 Aug 2023 16:13:01 GMT) Full text and rfc822 format available.

Message #14 received at 65424 <at> debbugs.gnu.org (full text, mbox):

From: Maxime Devos <maximedevos <at> telenet.be>
To: Julien Lepiller <julien <at> lepiller.eu>, 65424 <at> debbugs.gnu.org
Subject: Re: bug#65424: Guix doesn't use positional arguments in translated
 formatted messages
Date: Mon, 21 Aug 2023 18:12:08 +0200
[Message part 1 (text/plain, inline)]
> Proposed new documentation:
> 
> * 22.5.5 Translatable messages
> 
> When constructing translatable messages with 'format' (<reference to 
> guile manual>), it is important to use positional arguments.  For 
> example, instead of writing
> 
>    (format #t (G_ "The package '~a' is newer than '~a'.~%")
>               '("foo" "bar")),
> 
> you should write
> 
>    (format #t (G_ "The package '~1@*~a' is newer than '~2@*~a'.~%")
>               '("foo" "bar"))

Off-by-one error here
[OpenPGP_0x49E3EE22191725EE.asc (application/pgp-keys, attachment)]
[OpenPGP_signature (application/pgp-signature, attachment)]

This bug report was last modified 1 year and 298 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.