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

feat: use multi-language data for PDF title #73

Merged
merged 2 commits into from
Oct 25, 2024

Conversation

JKRhb
Copy link
Contributor

@JKRhb JKRhb commented Oct 24, 2024

When compiling a PDF using the template, I noticed that the multilanguage information was not yet used for the title metadata of the resulting file. This PR adjusts the template to use the lang_data to include that information.

@DeveloperPaul123
Copy link
Owner

Thanks for this!

Just curious, but does this work on your end? In any viewer I tested, the document title is not reflected when using the translated value.

image

I noted this from the typst docs as well regarding the document title.

The document's title. This is often rendered as the title of the PDF viewer window.
While this can be arbitrary content, PDF viewers only support plain text titles, so the conversion might be lossy.

If this does work for you, could you post what PDF viewer you're using as well?

@JKRhb
Copy link
Contributor Author

JKRhb commented Oct 24, 2024

Thank you for your swift response! :)

Hmm, in my case, it at least worked with the CV (using the German locale) and with Firefox as a PDF viewer:

image

But I will double-check this :)

@JKRhb
Copy link
Contributor Author

JKRhb commented Oct 24, 2024

I am very sorry, the output above actually came from a left-over manual adjustment of the document metadata :/ Sadly, the solution originally proposed in this PR actually does not work, probably partly because linguify returns Content instead of a string.

Based on a workaround mentioned in the linguify repository (see typst-community/linguify#7), I now managed to fix the issue, though :) The downside is that it required wrapping the set document call in a show rule to be able to access the context, which is required by the internal function from linguify that is now being used. This solution is not that pretty to be honest, but at least it works and could be refined in the future :)

@DeveloperPaul123
Copy link
Owner

Seems to work well! It is a bit hacky but I'm ok with this as this is obfuscated from the end user. Thanks for the PR!

@DeveloperPaul123 DeveloperPaul123 merged commit cf472b7 into DeveloperPaul123:main Oct 25, 2024
1 check passed
@JKRhb JKRhb deleted the multilang-pdf-title branch October 25, 2024 12:16
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