Skip to content

Support for localization of messages #753

Answered by svlandeg
toniwiki asked this question in Questions
Discussion options

You must be logged in to vote

Hi!

Both Click and Typer provide support for localization of messages, by wrapping hard-coded strings in the gettext wrapper as you can see in https://github.com/tiangolo/typer/blob/master/typer/core.py, e.g.

from gettext import gettext as _

if self.required:
    extra.append(_("required"))

(cf also relevant PRs for Click and Typer)

What this means is that eventually, you would be able to provide a translation of "(required)" in your own language, store that in a compiled dictionary, change the locale to your language, and then eventually Typer will print the translated version of this string in its help description for instance.

To use this feature, you'll need to set up a locales dire…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@toniwiki
Comment options

Answer selected by svlandeg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question or problem
2 participants
Converted from issue

This discussion was converted from issue #540 on March 19, 2024 15:44.