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: Frank Dana
Subject: [bug #61596] Support for Python f-strings
Date: Mon, 6 Nov 2023 17:12:52 -0500 (EST)

Follow-up Comment #6, bug #61596 (project gettext):

[comment #5 comment #5:]
> I suppose we shouldn't use f-strings in our code in the meanwhile, as long
as we want to internationalize the strings

Well, you shouldn't attempt to _translate_ f-strings, or (currently) to
translate _inside_ f-strings. Using f-strings themselves is fine.

IOW, this will never work, for the reasons @habile outlined:

intro = "Translatable string"
outro = "about something"
message = _(f"{intro} {outro}")


This _doesn't currently_ work, because the `msgfmt` tool doesn't capture the
two strings when collecting translatable inputs. Fixing that behavior is what
this bug is about:

message = f'{_("Translatable string")} {_("about something")}'


But, this equivalent form _will_ work just fine:

intro = _("Translatable string")
outro = _("about something")
message = f'{intro} {outro}'


(Obviously, you should never break a single translatable sentence into
multiple pieces like this. It's merely an example.)



    _______________________________________________________

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]