summaryrefslogtreecommitdiff
path: root/internal/web/render.go
diff options
context:
space:
mode:
Diffstat (limited to 'internal/web/render.go')
-rw-r--r--internal/web/render.go31
1 files changed, 18 insertions, 13 deletions
diff --git a/internal/web/render.go b/internal/web/render.go
index 63c1da4..ca5bb89 100644
--- a/internal/web/render.go
+++ b/internal/web/render.go
@@ -95,15 +95,17 @@ type ilLineView struct {
// In every mode, heading, citation (subtitle), verse-number and refrain
// text are wrapped in class="heading|citation|vnum|refrain|version-label"
// spans so theme CSS can restyle them; verse/paragraph text is escaped by
-// html/template.
-func RenderReadings(secs []liturgy.Section, versions []string, lectionary, display string) template.HTML {
+// html/template. lang localises the version-column labels and each section
+// heading's part-label word (render.LocalizeHeading, brief ยง3b); the
+// citation/verse text is never touched.
+func RenderReadings(secs []liturgy.Section, versions []string, lectionary, display, lang string) template.HTML {
switch display {
case "vertical":
- return renderTemplate("readings-vertical.html", buildColumnViews(secs, versions, lectionary))
+ return renderTemplate("readings-vertical.html", buildColumnViews(secs, versions, lectionary, lang))
case "interlinear":
- return renderTemplate("readings-interlinear.html", buildInterlinearViews(secs, versions, lectionary))
+ return renderTemplate("readings-interlinear.html", buildInterlinearViews(secs, versions, lectionary, lang))
default:
- return renderTemplate("readings.html", buildColumnViews(secs, versions, lectionary))
+ return renderTemplate("readings.html", buildColumnViews(secs, versions, lectionary, lang))
}
}
@@ -122,15 +124,17 @@ func renderTemplate(name string, data any) template.HTML {
// buildColumnViews gathers each section's per-version columns via
// render.GatherVersion -- the shared data both the "horizontal"
// (readings.html) and "vertical" (readings-vertical.html) templates range
-// over; only the surrounding markup differs between the two layouts.
-func buildColumnViews(secs []liturgy.Section, versions []string, lectionary string) []sectionView {
+// over; only the surrounding markup differs between the two layouts. lang
+// localises the column labels and the heading's part-label word (see
+// RenderReadings).
+func buildColumnViews(secs []liturgy.Section, versions []string, lectionary, lang string) []sectionView {
views := make([]sectionView, 0, len(secs))
for _, sec := range secs {
isPsalm := sec.PartID == "psalm"
cols := make([]columnView, 0, len(versions))
for _, v := range versions {
- label, blocks := render.GatherVersion(v, sec, lectionary)
+ label, blocks := render.GatherVersion(v, sec, lectionary, lang)
bviews := make([]blockView, 0, len(blocks))
for bi, b := range blocks {
@@ -148,7 +152,7 @@ func buildColumnViews(secs []liturgy.Section, versions []string, lectionary stri
}
views = append(views, sectionView{
- Heading: sec.Heading,
+ Heading: render.LocalizeHeading(sec.Heading, sec.PartID, lang),
Subtitle: sec.Subtitle,
PartID: sec.PartID,
Columns: cols,
@@ -175,8 +179,9 @@ func interlinearVersions(versions []string) []string {
// that version's order (stable, no duplicates). A version that comes back
// unversified (a bible lookup miss) is simply skipped -- the remaining
// versions still render. A section where nothing could be interleaved gets
-// a short escaped Note instead of an empty Verses list.
-func buildInterlinearViews(secs []liturgy.Section, versions []string, lectionary string) []ilSectionView {
+// a short escaped Note instead of an empty Verses list. lang localises the
+// per-version labels and the heading's part-label word (see RenderReadings).
+func buildInterlinearViews(secs []liturgy.Section, versions []string, lectionary, lang string) []ilSectionView {
mapped := interlinearVersions(versions)
type verseSet struct {
@@ -186,11 +191,11 @@ func buildInterlinearViews(secs []liturgy.Section, versions []string, lectionary
views := make([]ilSectionView, 0, len(secs))
for _, sec := range secs {
- view := ilSectionView{Heading: sec.Heading, Subtitle: sec.Subtitle, PartID: sec.PartID}
+ view := ilSectionView{Heading: render.LocalizeHeading(sec.Heading, sec.PartID, lang), Subtitle: sec.Subtitle, PartID: sec.PartID}
var sets []verseSet
for _, v := range mapped {
- label, verses, versified := render.GatherVerses(v, sec, lectionary)
+ label, verses, versified := render.GatherVerses(v, sec, lectionary, lang)
if !versified {
continue
}