Map Chinese region codes (`zh-TW`, `zh-CN`) to script codes when passing `lang` to Pandoc

Open Beginner friendly
#14,416 0 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
78/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Quiet
Tech stack
typescript
Domain
cli

Research direction

Start in src/command/render/pandoc.ts at the existing bare-zh rewrite, then review src/core/language.ts to confirm Quarto’s own language-file resolution remains unchanged. Reproduce with lang: zh-TW and a format using Pandoc translations, such as LaTeX/PDF with chapters. Done means the listed Chinese region codes are passed to Pandoc as the corresponding script codes without changing Quarto’s original lang value.

Written by the indexing model from the issue text.

Description

bug pandoc

When a user sets lang: zh-TW, Pandoc emits:

[WARNING] Could not load translations for zh-TW
  data file translations/zh.yaml not found

Pandoc ships only zh-Hans.yaml and zh-Hant.yaml (IETF-recommended script subtags for Chinese). Its fallback logic strips to the primary language subtag (zh), which also doesn't exist — hence the warning:

https://github.com/jgm/pandoc/blob/8799ad87b797e67577bc5368580685c3fa8e97fb/src/Text/Pandoc/Translations.hs#L58-L86

Quarto already has one special-case rewrite at pandoc invocation that rewrites bare zh to zh-Hans:

https://github.com/quarto-dev/quarto-cli/blob/e4b75c1a32902f6d6e01ac62752a5b7d02ec0a12/src/command/render/pandoc.ts#L1251-L1254

Suggestion

We could extend the mapping in pandoc.ts with region → script:

  • zh-TW, zh-HK, zh-MO → pass zh-Hant to Pandoc
  • zh-CN, zh-SG → pass zh-Hans to Pandoc

This would only affect the value handed to Pandoc. Quarto's own file resolution in src/core/language.ts would be unaffected — _language-zh-TW.yml would still load for users writing lang: zh-TW.

Repro

---
lang: zh-TW
---

Render any format that uses Pandoc translations (e.g. LaTeX/PDF with chapters). Warning appears in the render log.

From quarto-dev/quarto-cli#14409.

Dominant language
JavaScript
Stars
6k
Forks
458
Avg merge
1d 9h
Merged PRs (30d)
41

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from quarto-dev/quarto-cli

All issues in quarto-dev/quarto-cli

Similar issues

More JavaScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.