Skip to content

Document localisation of cross-reference titles/prefixes via the language key #14466

@mcanouil

Description

@mcanouil

What would you like to do?

Give feedback or suggest an improvement

Description

Follow-up to https://github.com/orgs/quarto-dev/discussions/14465.

The discussion confirmed that localisation of cross-reference titles and prefixes (for built-in floats, theorem environments, callouts, and custom kinds) is fully supported but not documented on https://quarto.org.
Users currently have to read _language.yml and infer the key naming convention from there.

What is supported but undocumented

Overriding cross-reference titles and prefixes for built-in floats and theorem environments via the language: key, e.g.:

---
lang: es
language:
  crossref-fig-title: "Figura"
  crossref-tbl-title: "Tabla"
  crossref-eq-prefix: "Ecuación"
---

The same mechanism works for callouts (crossref-nte-prefix, crossref-tip-prefix, crossref-wrn-prefix, crossref-imp-prefix, crossref-cau-prefix) and for any custom cross-reference kind, because the language filter passes through any key matching crossref-*-(title|prefix).

For the 11 float/theorem types (fig, tbl, lst, thm, lem, cor, prp, cnj, def, exm, exr), crossref-{type}-prefix defaults to crossref-{type}-title when omitted.

The per-language alternates pattern already documented for title-block-* keys works for crossref-* keys too:

lang: es
language:
  es:
    crossref-fig-title: "Figura"
  fr:
    crossref-fig-title: "Figure"

Pages that need updating on quarto.org

  • docs/authoring/language.qmd (Alternate Language section): the only example currently uses title-block-* keys.
    Add an example that uses crossref-*-title / crossref-*-prefix, and cross-link to the cross-references docs.
  • docs/authoring/cross-reference-options.qmd: clarify the relationship between crossref: { fig-title: ..., fig-prefix: ... } (per-document overrides) and language: { crossref-fig-title: ..., crossref-fig-prefix: ... } (locale-aware overrides), and list the supported keys.
  • docs/authoring/cross-references.qmd callout section / docs/authoring/_cross-references-callouts.qmd: add a localisation snippet showing how to translate callout prefixes such as crossref-nte-prefix.
  • docs/authoring/cross-references-custom.qmd: note that custom kinds inherit the same crossref-{type}-(title|prefix) localisation pattern.
  • Optionally, add a reference page at docs/reference/metadata/language.qmd similar to crossref.qmd.

Reference (for the docs author)

  • Keys are defined in src/config/constants.ts (kCrossref* constants) and enumerated in kLanguageDefaultsKeys.
  • Defaults and translations live in src/resources/language/_language*.yml.
  • Pass-through happens in src/command/render/filters.ts (languageFilterParams) via key.startsWith("crossref-"), plus the auto-derivation of crossref-{type}-prefix from crossref-{type}-title for the 11 float/theorem types.

Metadata

Metadata

Assignees

Labels

documentationDoc improvements & quarto-web

Type

No type
No fields configured for issues without a type.

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions