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

PDF translation support, and write XML using buffer #1849

Merged
merged 7 commits into from
Oct 24, 2023

Conversation

goose-life
Copy link
Contributor

No description provided.

@@ -205,7 +210,11 @@ def insert_frontmatter(self, document):
""" Generates the frontmatter and inserts it before the body (and coverpage if present) in the XML.
The document's document_xml isn't updated.
"""
# explicitly set the document's language for e.g. numbered title to be translated
activate(document.django_language)
Copy link
Contributor

Choose a reason for hiding this comment

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

rather user override() which ensures the deactivate is called if there is an error:

with override(document.django_language):
  frontmatter = ...

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thanks!

with open(xml_file, "wb") as f:
f.write(xml.encode('utf-8'))
# use io.open, BytesIO, getbuffer to avoid XML parse error in production
with io.open(xml_file, "wb") as f:
Copy link
Contributor

Choose a reason for hiding this comment

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

can you link to the issue this is trying to solve? I don't see how this change will fix anything.

Copy link
Contributor

Choose a reason for hiding this comment

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

@goose-life goose-life merged commit db4ef83 into master Oct 24, 2023
6 checks passed
@goose-life goose-life deleted the pdf-translations branch October 24, 2023 07:11
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.

2 participants