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

Implement --init-missing option for pybabel update #785

Merged
merged 3 commits into from Jun 15, 2021
Merged

Implement --init-missing option for pybabel update #785

merged 3 commits into from Jun 15, 2021

Conversation

RuRo
Copy link
Contributor

@RuRo RuRo commented May 7, 2021

Currently, if an output .po file doesn't exist during pybabel update, the update fails when trying to open the missing file. This PR adds a boolean --init-missing option. If this option is enabled during an update and an output .po file is missing, it is created and initialized the same way it would be by pybabel init.


Before this PR you had to run two commands like

pybabel init   --domain=${DOM} --locale=${LOC} --input-file=pot/${DOM}.pot --output-dir=po/
pybabel update --domain=${DOM} --locale=${LOC} --input-file=pot/${DOM}.pot --output-dir=po/

if po/${LOC}/LC_MESSAGES/${DOM}.po didn't exist.

If the file did already exist, you had to only run the second command (otherwise, running init on an existing file overwrites it, removing any previous translations, which is not desirable).


After this PR you will be able to run a single command and get the expected behaviour, no matter if the output file existed previously or not:

pybabel update --init-missing --domain=${DOM} --locale=${LOC} --input-file=pot/${DOM}.pot --output-dir=po/

@RuRo
Copy link
Contributor Author

RuRo commented May 10, 2021

@akx Sorry to ping you, but what's a cowboy gotta do 'round here to get his PR reviewed 🤠?

Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

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

The code looks good, thank you.

I'd appreciate a non-trivial test that does test that this option also does initialize the files as it promises.

@RuRo
Copy link
Contributor Author

RuRo commented May 26, 2021

@akx Done.

@RuRo RuRo requested a review from akx June 5, 2021 08:18
Copy link
Member

@akx akx left a comment

Choose a reason for hiding this comment

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

Looks good, thanks. Sorry for the delay in reviewing!

@akx akx merged commit 96acf86 into python-babel:master Jun 15, 2021
@akx akx added this to the Babel 2.10 milestone Jan 28, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants