Skip to content

Commit d40b8ec

Browse files
i18n for typst
includes change to typst-template.typ which should be reverted when we get a fix for jgm/pandoc#9724 This also fixes #9854 crash for subfigures with no ids
1 parent 7307b1a commit d40b8ec

7 files changed

Lines changed: 64 additions & 7 deletions

File tree

news/changelog-1.5.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ All changes included in 1.5:
7878
- ([#9671](https://github.com/quarto-dev/quarto-cli/issues/9671)): Reimplement `typst` subfloats to fix subfloat counters.
7979
- ([#9694](https://github.com/quarto-dev/quarto-cli/issues/9694)): Fix default callout (`::: callout ... ::: `) in Typst.
8080
- ([#9722](https://github.com/quarto-dev/quarto-cli/issues/9722)): Resolve data URI images in Typst.
81+
- ([#9555](https://github.com/quarto-dev/quarto-cli/issues/9555)): Text elements in Typst are internationalized.
8182
- Upgrade Typst to 0.11
8283
- Upgrade the Typst template to draw tables without grid lines by default, in accordance with latest Pandoc.
8384

src/resources/filters/customnodes/floatreftarget.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -988,7 +988,7 @@ end, function(float)
988988
-- luacov: enable
989989
end
990990
local kind = "quarto-float-" .. ref
991-
local supplement = info.name
991+
local supplement = titleString('fig', info.name)
992992
-- FIXME: custom numbering doesn't work yet
993993
-- local numbering = ""
994994
-- if float.parent_id then

src/resources/filters/customnodes/theorem.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ local function ensure_typst_theorems(reftype)
100100
letted_typst_theorem[reftype] = true
101101
local theorem_type = theorem_types[reftype]
102102
quarto.doc.include_text("in-header", "#let " .. theorem_type.env .. " = thmbox(\"" ..
103-
theorem_type.env .. "\", \"" .. theorem_type.title .. "\")")
103+
theorem_type.env .. "\", \"" .. titleString(reftype, theorem_type.title) .. "\")")
104104
end
105105
end
106106

src/resources/filters/layout/pandoc3_figure.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ function render_pandoc3_figure()
161161
caption = figure.caption.long[1],
162162
kind = "quarto-float-fig",
163163
caption_location = crossref.categories.by_ref_type["fig"].caption_location,
164-
supplement = "Figure",
164+
supplement = titleString('fig', 'Figure'),
165165
})
166166
end
167167
}

src/resources/filters/layout/typst.lua

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ end, function(layout)
9595
return float.content
9696
-- luacov: enable
9797
end
98-
local supplement = info.name
98+
local supplement = titleString(ref, info.name)
9999

100100
-- typst output currently only supports a single grid
101101
-- as output, so no rows of varying columns, etc.
@@ -133,12 +133,12 @@ end, function(layout)
133133
_quarto.format.typst.as_typst_content(cells)
134134
}, false))
135135
else
136-
result:insert(make_typst_figure {
136+
result:extend(make_typst_figure {
137137
content = cells,
138138
caption_location = caption_location,
139139
caption = layout.float.caption_long,
140140
kind = kind,
141-
supplement = info.prefix,
141+
supplement = titleString(ref, info.prefix),
142142
numbering = info.numbering,
143143
identifier = layout.float.identifier
144144
})

src/resources/formats/typst/pandoc/quarto/typst-template.typ

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@
6161

6262
if abstract != none {
6363
block(inset: 2em)[
64-
#text(weight: "semibold")[Abstract] #h(1em) #abstract
64+
#text(weight: "semibold")[$labels.abstract$] #h(1em) #abstract
6565
]
6666
}
6767

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
title: "Typst internationalization"
3+
lang: es
4+
abstract: Escribo algo.
5+
format:
6+
typst:
7+
keep-typ: true
8+
_quarto:
9+
tests:
10+
typst:
11+
ensureTypstFileRegexMatches:
12+
- ['Resumen', 'Nota', 'Conjetura']
13+
- []
14+
ensurePdfRegexMatches:
15+
- ['Figura 1', 'Figura 2', 'Figura 3', 'Figura 4', 'Figura 5', 'Figura 6']
16+
- ['Figure 1', 'Figure 2', 'Figure 3', 'Figure 4', 'Figure 5', 'Figure 6']
17+
---
18+
19+
![Marcador]({{< placeholder 300 >}}){#fig-marcador}
20+
21+
![Marcador desconocido]({{< placeholder 300 >}})
22+
23+
::: {#fig-panel layout-ncol=2}
24+
25+
![Marcador]({{< placeholder 200 >}}){#fig-layout-a}
26+
27+
![Marcador]({{< placeholder 200 >}}){#fig-layout-b}
28+
29+
Panels
30+
31+
:::
32+
33+
::: {#fig-panel2 layout-ncol=2}
34+
35+
![Marcador]({{< placeholder 200 >}})
36+
37+
![Marcador]({{< placeholder 200 >}})
38+
39+
Panels
40+
41+
:::
42+
43+
44+
::: {.callout-note}
45+
46+
Información
47+
48+
:::
49+
50+
::: {#cnj-redondo}
51+
52+
# Redondo
53+
54+
El mundo es redondo.
55+
56+
:::

0 commit comments

Comments
 (0)