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

Fluent scope leakage issue in bibliography #2054

Closed
Omikhleia opened this issue Jun 10, 2024 · 2 comments · Fixed by #2062
Closed

Fluent scope leakage issue in bibliography #2054

Omikhleia opened this issue Jun 10, 2024 · 2 comments · Fixed by #2062
Assignees
Labels
bug Software bug issue modules:packages Issue relates to core or 3rd party packages packages:bibliography
Milestone

Comments

@Omikhleia
Copy link
Member

Language changes in bilbliography (e.g. caused by an "et al") leak beyond the expected scope.

Minimal example

Bibliography

@phdthesis{Thesis,
  author  = {Smith, Jane and Doe, John and Wilbur, Norbert and Mac, Donald},
  title   = {A Thesis},
  school  = {Institute of Technobabble},
  year    = {2016},
}

@book{Book,
  author     = {Doe, John and Smith, Jane},
  translator = {Pumpernickel, Peter},
  title      = {A Book},
  year       = {2020},
}

Document:

\begin[papersize=a6]{document}
\use[module=packages.bibtex]
\language[main=en]
\loadbibliography[file=temp/biblite.bib]

\reference{Book}

\reference{Thesis}

\reference{Book}

\end{document}

Obtained

image

The third book reference has latin text where it shoudn't.

Analysis

The bibliography package uses fluent:get_message() directly.
Due to fluent not being stateless and having its own global local state, there's a scope leakage. (It does ring an old bell #1477...)

Of course, a possible quick fix would be to systematically invoke fluent:set_locale(SILE.settings:get("document.language")) before any call to fluent:get_message() in the bibliography package -- I'll leave it to the readers to judge whether it is a sane and nice solution...

@Omikhleia Omikhleia added bug Software bug issue modules:packages Issue relates to core or 3rd party packages labels Jun 10, 2024
@Omikhleia
Copy link
Member Author

a possible quick fix would be

N.B. Now that we have hooks on settings, it might also be possible to switch fluent's global locale in such a hook...

@alerque alerque self-assigned this Jun 12, 2024
@alerque
Copy link
Member

alerque commented Jun 12, 2024

Using a setting hook for this makes a lot of sense now that we have that mechanism, and I just tried it and it eliminated a lot of cognitive overhead about internals and hanky-panky calls to set the locale needed to get things done as expected.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Software bug issue modules:packages Issue relates to core or 3rd party packages packages:bibliography
Projects
Development

Successfully merging a pull request may close this issue.

2 participants