-
First Check
Commit to Help
Example Codepython -m my-cli-app --help DescriptionI am interested in creating a CLI application with Typer that supports multiple languages. To do this I want to be able to localize automatically generated default strings in help, error messages, etc. I am new to Typer (and Python in general) but I think I understand that Click is the one that wraps the internal strings with gettext. However, it is not clear to me how I can change the default messages from Typer. Could someone give me a simple example of how to do it? Thanks Operating SystemLinux Operating System DetailsNo response Typer Version0.7.0 Python Version3.10.9 Additional ContextNo response |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
Hi! Both Click and Typer provide support for localization of messages, by wrapping hard-coded strings in the
(cf also relevant PRs for Click and Typer) What this means is that eventually, you would be able to provide a translation of To use this feature, you'll need to set up a |
Beta Was this translation helpful? Give feedback.
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.(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…