quarto-dev / quarto-dev/quarto-cli
[FR] How to manage languages in a PDF Quarto book that has chapters with different languages?
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 6k
- Forks
- 458
- Avg merge
- 1d 9h
- Merged PRs (30d)
- 41
Description
See the discussion at
the following is a sumup of what has been originally posted by KleinWurm July 1, 2025
I am trying to write a Quarto book in French but some of its chapter are in English.
(...)
Using instruction from Document Language, I used the file _quarto.yml as follows:
project:
type: book
book:
title: "La marmotte"
chapters:
- index.qmd
- en_chapter.qmd
- fr_chapter.qmd
- references.qmd
bibliography: references.bib
lang: fr-FR # main language (for references, lof and lot, etc.)
format:
pdf:
documentclass: scrreprt
lof: true
editor: visual
For the chapters written in another language, I put the following at the top of the chapter file:
---
lang: en-GB # this chapter uses a different language than the main book.
---
A reproducible example is available here: https://github.com/KleinWurm/quarto-book-languages-test/
For this kind of usage, setting lang attribute is not working in single file book like PDF, as global lang will be override by chapter one.
Using Pandoc's lang solution with fenced div works (https://pandoc.org/MANUAL.html#language-variables)
::: {lang="en-EN"}
something in english in a french doc
:::
However, Quarto does not integrate with that and Cross reference won't be in English in this chapter : Our document language approach is only global (https://quarto.org/docs/authoring/language.html
IDEAS for Quarto to support this kind of multi language
Support lang in a chapter
Quarto could catch this YAML meta as it is doing for title or other, instead of passing it through. This way it could create the fenced div for the user for the whole chapter.
So a user would write
---
lang: en-GB
---
Content of the chapter
instead of
::: {lang='en-GB'}
Content of the chapter
:::
more idiomatic to set attribute on the page with Quarto.
Though, how would this behave in multi file book.
Add support for document language change for Pandoc's block with language attributes
Depending on how our document language feature works, could we catch the Div with lang attribute and go use the other _language-<lang>.yml file information to use for the reference on the page. This would be limited to cross reference language and other in page translatation.
This issue is for storing this two ideas in case other usage or 👍 are coming for this.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the linked discussion, the reproducible example, and the _quarto.yml configuration to understand the current chapter-language behavior. Compare the chapter lang metadata with Pandoc's fenced-div language solution and Quarto's document-language guidance. The scope and expected behavior for multi-file books, cross-references, and translated labels need to be decided before implementation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- markdown, yaml
- Domain
- internationalization, localization
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100