bug-gettext
[Top][All Lists]
Advanced

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

[bug #61596] Support for Python f-strings


From: Bruno Haible
Subject: [bug #61596] Support for Python f-strings
Date: Tue, 7 Dec 2021 11:41:08 -0500 (EST)
User-agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:94.0) Gecko/20100101 Firefox/94.0

Update of bug #61596 (project gettext):

                  Status:                    None => Not a Bug              
             Assigned to:                    None => haible                 
             Open/Closed:                    Open => Closed                 

    _______________________________________________________

Follow-up Comment #2:

Supporting this kind of strings in xgettext in the naïve way, i.e. where the
string itself would appear as an msgid in the PO file, is not appropriate for
the following reasons:

1) PEP 498 says "It should be noted that an f-string is really an expression
evaluated at run time". But the translator is not a programmer. An expression
from a programming language is just gibberish to a translator; we should not
expose translators to that.

2) The translator would have the ability to change the expressions that occur
inside an f-string. (Even if 'msgfmt -c' checks against that; some tool don't
invoke msgfmt with the '-c' option.) To make this safe, the verification that
the expressions have not been modified during translation would have to occur
at runtime.

3) When the programmer changes the subexpressions, this would lead to a
modified POT file, and work for the translators ensues.

It would be possible to write into the POT file a derived string, e.g. in your
example '<label>{0}:</label>'. But then we need a runtime function that
substitutes expression values into a format string that comes from a
translator. Still, the added complexity feels awkward. It is better to let the
programmer change their program, to separate internationalization and
formatting, so that it uses one of the two supported format string syntaxes:
'...%(ident)d...' % { 'ident': value }
'...{ident}...'.format(ident=value)


    _______________________________________________________

Reply to this item at:

  <https://savannah.gnu.org/bugs/?61596>

_______________________________________________
  Message sent via Savannah
  https://savannah.gnu.org/




reply via email to

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