aboutsummaryrefslogtreecommitdiff
path: root/internal/psalter/psalter.go
blob: 815f66059d6ddcddb5364e0ca1fda6ef00d4db20 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Package psalter bridges psalm versification between the Vulgate-family
// versions and the Douay-Rheims source. See the Go port of psalm_versify.py.
package psalter

// DRBTitleFold maps a Hebrew psalm number to the number of title verses the DRB
// source folds into verse 1 (1, or 2 for a historical superscription). Untitled
// psalms are absent (k = 0). Copy every entry from psalm_versify.py DRB_TITLE_FOLD.
var DRBTitleFold = map[int]int{
	3: 1, 4: 1, 5: 1, 6: 1, 7: 1, 8: 1, 11: 1, 12: 1, 14: 1, 18: 1, 19: 1,
	20: 1, 21: 1, 22: 1, 30: 1, 31: 1, 34: 1, 36: 1, 38: 1, 39: 1, 40: 1,
	41: 1, 42: 1, 44: 1, 45: 1, 46: 1, 47: 1, 48: 1, 49: 1, 51: 2, 52: 2,
	53: 1, 54: 2, 55: 1, 56: 1, 57: 1, 58: 1, 59: 1, 60: 2, 61: 1, 62: 1,
	63: 1, 64: 1, 65: 1, 67: 1, 68: 1, 69: 1, 70: 1, 75: 1, 76: 1, 77: 1,
	80: 1, 81: 1, 83: 1, 84: 1, 85: 1, 88: 1, 89: 1, 92: 1, 102: 1, 108: 1,
	140: 1, 142: 1,
}

// DrbVerse returns the DRB-source verse number for a lectionary (BT) psalm verse.
func DrbVerse(hebrewPsalm, lectionaryVerse int) int {
	v := lectionaryVerse - DRBTitleFold[hebrewPsalm]
	if v < 1 {
		return 1
	}
	return v
}

// HebrewToVulgateChapter maps a Masoretic psalm number to its Vulgate chapter.
func HebrewToVulgateChapter(h int) int {
	switch {
	case h <= 8 || h >= 148:
		return h
	case h >= 9 && h <= 10:
		return 9
	case h >= 11 && h <= 113:
		return h - 1
	case h >= 114 && h <= 115:
		return 113
	case h == 116:
		return 114
	case h >= 117 && h <= 146:
		return h - 1
	case h == 147:
		return 146
	}
	return h
}