Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Improve support for CLI translations using gettext #417

Merged
merged 5 commits into from Mar 23, 2024

Conversation

mjodmj
Copy link
Contributor

@mjodmj mjodmj commented Jul 10, 2022

Just adding some missing wrappings of strings around gettext which some may need for the sake of CLI i18n.

Copy link

@ereslibre ereslibre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just chiming in to say that it would be nice to have this one merged :)

Edit: this PR might also consider removing the TODO about this very change:

typer/typer/core.py

Lines 623 to 626 in 046d3e2

# TODO: explore adding Click's gettext support, e.g.:
# from gettext import gettext as _
# with formatter.section(_("Options")):
# ...

@svlandeg svlandeg added bug Something isn't working p2 labels Mar 6, 2024
@svlandeg svlandeg marked this pull request as draft March 19, 2024 14:26
@svlandeg svlandeg marked this pull request as ready for review March 19, 2024 15:02
Copy link
Collaborator

@svlandeg svlandeg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for your contribution!

I took the liberty of updating your PR with the latest changes from master. This looks good to me.

@ereslibre
Copy link

ereslibre commented Mar 19, 2024

Thanks @svlandeg! I do wonder if we should also update some of the strings at

DEPRECATED_STRING = "(deprecated) "
DEFAULT_STRING = "[default: {}]"
ENVVAR_STRING = "[env var: {}]"
REQUIRED_SHORT_STRING = "*"
REQUIRED_LONG_STRING = "[required]"
RANGE_STRING = " [{}]"
ARGUMENTS_PANEL_TITLE = "Arguments"
OPTIONS_PANEL_TITLE = "Options"
COMMANDS_PANEL_TITLE = "Commands"
ERRORS_PANEL_TITLE = "Error"
ABORTED_TEXT = "Aborted."

If you are fine with it I can create a PR if you don't want to update this one with those.

@svlandeg
Copy link
Collaborator

Good idea to add those @ereslibre - I've pushed directly to this PR to keep the work together. Feel free to review!

@tiangolo tiangolo changed the title Add some wraps around gettext ✨ Improve support for CLI translations uisng gettext Mar 23, 2024
@tiangolo tiangolo added feature New feature, enhancement or request and removed bug Something isn't working labels Mar 23, 2024
@tiangolo tiangolo merged commit fe9538c into tiangolo:master Mar 23, 2024
18 checks passed
@tiangolo
Copy link
Owner

Great, thank you @mjodmj! 🤓

And thanks for the review @svlandeg 🙇

This will be available in Typer 0.9.4 in the next few hours. 🚀

@tiangolo tiangolo changed the title ✨ Improve support for CLI translations uisng gettext ✨ Improve support for CLI translations using gettext Mar 23, 2024
@ereslibre
Copy link

@tiangolo did beat me to it! Sorry for the lag on the review and thank you everyone involved :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature, enhancement or request p2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants