Skip to content

fix: let later language keys beat per-language files - #15350

Open
mcanouil wants to merge 6 commits into
quarto-dev:mainfrom
mcanouil:fix/language-variation-override-15349
Open

mcanouil wants to merge 6 commits into
quarto-dev:mainfrom
mcanouil:fix/language-variation-override-15349

Conversation

@mcanouil

@mcanouil mcanouil commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

Fixes #15349.

Description

A per-language file such as _language-fr.yml is read into a fr block next to the plain keys of its language map, and translationsForLang applies that block last.
So a plain key set by a later layer lost to an earlier fr block as soon as lang: fr was set.
This hit extensions against the document, a project's language: file against a page, the project's own _language-fr.yml against its inline keys, and the front matter against metadata-files.

The new mergeLanguages in src/core/language.ts fixes the merge itself, so it doesn't depend on lang.
A plain key from a later layer also removes that key from the locale blocks of the earlier layers.
Within one layer, a fr: value still wins over that layer's plain key.
mergeFormatMetadata, mergeProjectMetadata and mergeQuartoConfigs use it for language, and so does the merge of _language.yml with the inline project keys.

Four smoke tests under tests/docs/smoke-all/2026/11/12/ cover these cases and fail without the fix.
Unit tests in tests/unit/core/language-merge.test.ts pin down the merge rules.

The ipynb-filters re-merge in render-contexts.ts still uses plain mergeConfigs.
I left it alone because there is no fixture to test it with.

Checklist

I have (if applicable):

  • referenced the GitHub issue this PR closes
  • updated the appropriate changelog in the PR
  • ensured the present test suite passes
  • added new tests
  • created a separate documentation PR in Quarto's website repo and linked it to this PR

A per-language file such as `_language-fr.yml` is stored as a variation
object that applies on top of the plain keys. When a later layer (the
document, or the inline `language:` of `_quarto.yml`) set the same key
as a plain key, the earlier variation still won once `lang` matched.

A plain key from a later layer now also removes that key from the
variations of the earlier layers. A variation still wins over the plain
keys of its own layer.

Fixes quarto-dev#15349
@mcanouil mcanouil added the bug Something isn't working label Nov 12, 2026
@mcanouil mcanouil self-assigned this Nov 12, 2026
@posit-snyk-bot

posit-snyk-bot commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues
✅ Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

Profiles, `metadata-files` includes and project type extensions merge
through `mergeProjectMetadata`, so a plain `language` key there could
still lose to an earlier per-language variation.
`mergeLanguages` now rewrites only plain-object locale blocks, and skips
the pass when the later layer sets no plain key, so an array value under
`language:` stays an array. The merge rules and localisation notes now
describe the cross-layer `language` merge.
Document front matter, `metadata-files` and `--metadata` merge through
`mergeQuartoConfigs`, so a plain `language` key from a metadata file
could still lose to a locale block in the front matter. The merging
architecture notes now describe the `language` rule.
Point the localisation notes at the moved functions, and say in the changelog that inline locale blocks are covered too.
@mcanouil
mcanouil marked this pull request as ready for review November 12, 2026 13:23
…ion-override-15349

# Conflicts:
#	news/changelog-1.12.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Document language keys do not override the per-language file of an extension

2 participants