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

fix gettext builder that writes pot files unless the content are same without creation date #3490

Merged
merged 1 commit into from Mar 2, 2017

Conversation

shibukawa
Copy link
Contributor

… without creation date

Subject:

Feature or Bugfix

  • Bugfix

Purpose

  • gettext builder always writes pot files even if the content is not changed. It is not suitable when these files are managed with VCS.

Detail

  • Check old content before writing.

Relates

Copy link
Member

@shimizukawa shimizukawa left a comment

Choose a reason for hiding this comment

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

LGTM

old_body_index = old_content.index('"PO-Revision-Date:')
new_body_index = new_content.index('"PO-Revision-Date:')
return ((old_content[:old_header_index] != new_content[:new_header_index]) or
(new_content[new_body_index:] != old_content[old_body_index:]))
Copy link
Contributor

Choose a reason for hiding this comment

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

It is compares chunk before POT-Creation date and chunk after and including PO-Revision-Date. I guess the later doesn't change, but there might a better option to compare using sets. https://stackoverflow.com/questions/19007383/compare-two-different-files-line-by-line-in-python/19007888#19007888

Copy link
Member

Choose a reason for hiding this comment

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

Indeed, our template for .po file: POHEADER has fixed PO-Revision-Date. It's immutable.

 "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"

And current time is used for POT-Creation-Date:. so should_write() would return True.

So we have to compare without these headers.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants