How to use gettext with python >3.6 f-strings

前端 未结 2 1518
忘了有多久
忘了有多久 2020-12-17 07:43

Previously you would use gettext as following:

_(\'Hey {},\').format(username)

but what about new Python\'s f-string?

2条回答
  •  粉色の甜心
    2020-12-17 08:25

    'Hey {},' is contained in your translation dictionary as is.

    If you use f'Hey {username},', that creates another string, which won't be translated.

    In that case, the format method remains the only one useable.

提交回复
热议问题