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

Remove generated translation binaries from repo #199

Merged
merged 4 commits into from Apr 25, 2021
Merged

Remove generated translation binaries from repo #199

merged 4 commits into from Apr 25, 2021

Conversation

hugovk
Copy link
Collaborator

@hugovk hugovk commented Apr 19, 2021

Fixes #198

Changes proposed in this pull request:

  • Remove the .mo files from the repo and .gitignore them
  • Add a script to generate them (requires gettext/msgfmt)
  • Install gettext/msgfmt and and generate files on CI for Linux and macOS
  • It's a bit harder to install on CI for Windows, skip installation there
  • Skip tests requiring .mo files if not found, the tester may not have gettext/msgfmt (like Windows CI)
  • Add step to release checklist to generate .mo files

@hugovk
Copy link
Collaborator Author

hugovk commented Apr 19, 2021

Python 3.10-dev failures are due to GHA using some sort of 3.10 beta, but 3.10 isn't actually in beta yet, and pytest isn't quote yet ready for 3.10 beta:

Will ignore for now, should be resolved soon enough.

@codecov-commenter
Copy link

codecov-commenter commented Apr 19, 2021

Codecov Report

Merging #199 (a759892) into master (98fafaf) will increase coverage by 0.00%.
The diff coverage is 100.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master     #199   +/-   ##
=======================================
  Coverage   99.83%   99.83%           
=======================================
  Files           9        9           
  Lines         604      608    +4     
=======================================
+ Hits          603      607    +4     
  Misses          1        1           
Flag Coverage Δ
GHA_Ubuntu 99.17% <0.00%> (-0.66%) ⬇️
GHA_Windows 98.68% <100.00%> (-1.16%) ⬇️
GHA_macOS 99.17% <0.00%> (-0.66%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
tests/test_i18n.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 98fafaf...a759892. Read the comment docs.

@hugovk hugovk added the changelog: Changed For changes in existing functionality label Apr 19, 2021
echo "$locale"
# compile to binary .mo
msgfmt --check -o src/humanize/locale/$locale/LC_MESSAGES/humanize{.mo,.po}
done
Copy link
Contributor

Choose a reason for hiding this comment

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

My only comment is that if msgfmt --check fails, for example if in the translation of the string "%d months" you forget the "%d", then this should stop and get fixed. You may need to check the exit code and act accordinly.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, good point. I checked it in another branch. A change like this:

diff --git a/src/humanize/locale/ca_ES/LC_MESSAGES/humanize.po b/src/humanize/locale/ca_ES/LC_MESSAGES/humanize.po
index 5e6a4f2..abdc464 100644
--- a/src/humanize/locale/ca_ES/LC_MESSAGES/humanize.po
+++ b/src/humanize/locale/ca_ES/LC_MESSAGES/humanize.po
@@ -221,8 +221,8 @@ msgstr "un mes"
 #, python-format
 msgid "%d month"
 msgid_plural "%d months"
-msgstr[0] "%d mes"
-msgstr[1] "%d mesos"
+msgstr[0] "mes"
+msgstr[1] "mesos"

 #: src/humanize/time.py:174
 msgid "a year"

hugovk/humanize@cfa2788

Fails on the CI like this:

Run scripts/generate-translation-binaries.sh
ca_ES
src/humanize/locale/ca_ES/LC_MESSAGES/humanize.po:224: number of format specifications in 'msgid_plural' and 'msgstr[0]' does not match
msgfmt: found 2 fatal errors
Error: Process completed with exit code 1.

https://github.com/hugovk/humanize/runs/2431670085?check_suite_focus=true

Copy link
Contributor

Choose a reason for hiding this comment

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

This is great. Thanks!

@jordimas
Copy link
Contributor

Looks good to me. Thanks

@hugovk hugovk merged commit fb2daf3 into jmoiron:master Apr 25, 2021
@hugovk hugovk deleted the generate-translation-binaries branch April 25, 2021 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
changelog: Changed For changes in existing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Generate files during built process
3 participants