Skip to content

Improve Language Handling#78

Merged
PgBiel merged 16 commits intotypst:mainfrom
DerDrodt:lang
Jun 1, 2025
Merged

Improve Language Handling#78
PgBiel merged 16 commits intotypst:mainfrom
DerDrodt:lang

Conversation

@Drodt
Copy link
Copy Markdown
Contributor

@Drodt Drodt commented May 30, 2025

As discussed by @PgBiel in typst/hayagriva#317 (comment), biblatex does not handle languages correctly: First, they can be a list and second, we should actually parse the language identifiers used. This PR does just that.

Also applies some clippy fixes and uses Rust 1.85 in the CI, just as Typst and hayagriva.

@PgBiel
Copy link
Copy Markdown
Contributor

PgBiel commented May 30, 2025

Thank you!
What do you think of implementing the conversion from Language to unic_langid::LanguageIdentifier in this crate directly? To avoid an unnecessary dependency for downstream users, maybe we can keep unic_langid as an optional dependency (that is, a feature) and enable it on Hayagriva.

In addition, since this change is directly linked to typst/hayagriva#317, do you think you can adapt your PR on the hayagriva side to use these changes? You can use a git dependency on your biblatex fork for the time being so CI passes. The PRs can then be merged together.

Also applies some clippy fixes and uses Rust 1.85 in the CI, just as Typst and hayagriva.

Can you do this in a separate PR? Should be a speedy merge for that part then.

@Drodt
Copy link
Copy Markdown
Contributor Author

Drodt commented May 30, 2025

Thank you! What do you think of implementing the conversion from Language to unic_langid::LanguageIdentifier in this crate directly? To avoid an unnecessary dependency for downstream users, maybe we can keep unic_langid as an optional dependency (that is, a feature) and enable it on Hayagriva.

Can do. I like the feature idea.

In addition, since this change is directly linked to typst/hayagriva#317, do you think you can adapt your PR on the hayagriva side to use these changes? You can use a git dependency on your biblatex fork for the time being so CI passes. The PRs can then be merged together.

Yes, that was my next step. Just wanted to see the general reaction first. Thanks :)

Also applies some clippy fixes and uses Rust 1.85 in the CI, just as Typst and hayagriva.

Can you do this in a separate PR? Should be a speedy merge for that part then.

Good point. See #79

@PgBiel
Copy link
Copy Markdown
Contributor

PgBiel commented May 30, 2025

Just wanted to see the general reaction first.

Yeah, that's totally fair. Feel free to proceed with it then.

@PgBiel
Copy link
Copy Markdown
Contributor

PgBiel commented May 30, 2025

While we're at it, it might be a good idea to supersede this PR by adding the langid field: #55

I think the main difference from the language field is that only one can be specified, per the biblatex manual:

langid field (identifier)

The language id of the bibliography entry. The alias hyphenation is provided for backwards compatibility. The identifier must be a language name known to the babel/polyglossia packages. This information may be used to switch hyphenation patterns and localise strings in the bibliography.

@Drodt
Copy link
Copy Markdown
Contributor Author

Drodt commented May 30, 2025

While we're at it, it might be a good idea to supersede this PR by adding the langid field: #55

I think the main difference from the language field is that only one can be specified, per the biblatex manual:

langid field (identifier)
The language id of the bibliography entry. The alias hyphenation is provided for backwards compatibility. The identifier must be a language name known to the babel/polyglossia packages. This information may be used to switch hyphenation patterns and localise strings in the bibliography.

I added it. But should it also be a PermissiveType? Or are we as strict as the biblatex doc sounds?

@PgBiel
Copy link
Copy Markdown
Contributor

PgBiel commented May 30, 2025

I suppose an invalid langid would probably be problematic in a LaTeX document using biblatex, though I guess there could be different standards for this field. Maybe we can keep it permissive for now...

Copy link
Copy Markdown
Contributor

@PgBiel PgBiel left a comment

Choose a reason for hiding this comment

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

Looking good.

Drodt and others added 10 commits June 1, 2025 06:17
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
Co-authored-by: PgBiel <9021226+PgBiel@users.noreply.github.com>
@Drodt
Copy link
Copy Markdown
Contributor Author

Drodt commented Jun 1, 2025

Sorry for the typos! It's all ready now

@PgBiel PgBiel merged commit 96751bf into typst:main Jun 1, 2025
2 checks passed
@PgBiel
Copy link
Copy Markdown
Contributor

PgBiel commented Jun 1, 2025

Thank you! 💙

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