-
-
Notifications
You must be signed in to change notification settings - Fork 30.3k
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
Add translation tests for argparse #124295
Comments
Continuing the discussion here since the other issue was closed. Quoting Serhiy:
I was originally thinking the same, but to me that seems like a lot of effort compared to the benefit we'd get. Instead, I think that using a message extractor (e.g. pygettext) we can assert both the presence of a specific message and the line number it appears at. This should give us pretty much the same confidence as directly checking the argparse output but with an order of magnitude less work. What do you think? |
Would not this make the tests extremely fragile? |
Does it matter that much if you don't need to fix the tests manually? You'd have a snapshot of the PO file and a simple command to regenerate it so all you'd need to do is double-check the diff |
You would need to regenerate the snapshot after every change in But this is a good first step. Before #27667 was merged, |
True, if the module is changing a lot, so would the snapshots. I'll try to come up with a PR based on your suggestions :) |
We should also add translation tests for |
Agreed, I can take care of that once we're done with argparse.
A common folder for all translation data sounds like a good idea! |
@serhiy-storchaka The PR also separates the translation tests into its own files which necessitates turning argparse tests into a package. Would you prefer that I merge the translation tests with |
Yes, of course. |
…124803) (cherry picked from commit 0922a4a) Co-authored-by: Tomas R. <[email protected]>
Thank you for your contribution @tomasr8. If you wish, you can create new issues and PRs for |
I'll look into that :) |
…126046) (cherry picked from commit 0922a4a) Co-authored-by: Tomas R. <[email protected]>
…thonGH-124803) (pythonGH-126046) (cherry picked from commit 0922a4a) (cherry picked from commit ff044ed) Co-authored-by: Serhiy Storchaka <[email protected]> Co-authored-by: Tomas R. <[email protected]>
It does not catch |
IIRC pygettext currently does not know how to handle For example invoking
Produces several warnings (and does not extract any ngettext strings):
We could fix pygettext to allow functions like ngettext. We could probably use the same syntax that GNU's xgettext and pybabel use to specify keywords and their arguments: https://www.gnu.org/software/gettext/manual/html_node/xgettext-Invocation.html#index-_002dk_002c-xgettext-option |
For beginning, it should support all |
While #12711 was merged, it seems like there's a separate issue worth tracking around adding translation tests for argparse (see #12711 (comment))
Linked PRs
The text was updated successfully, but these errors were encountered: