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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
package i18n
import (
"strings"
"testing"
)
func TestGetTheme(t *testing.T) {
if got := Get("pl").Theme; got != "motyw" {
t.Errorf(`Get("pl").Theme = %q, want "motyw"`, got)
}
if got := Get("en").Theme; got != "theme" {
t.Errorf(`Get("en").Theme = %q, want "theme"`, got)
}
}
func TestGetUnknownFallsBackToEnglish(t *testing.T) {
en := Get("en")
if got := Get("xx"); got.Theme != en.Theme || got.BannerGospel != en.BannerGospel {
t.Errorf(`Get("xx") = %+v, want the English set %+v`, got, en)
}
if got := Get(""); got.Theme != en.Theme || got.BannerGospel != en.BannerGospel {
t.Errorf(`Get("") = %+v, want the English set %+v`, got, en)
}
}
func TestVersionLabels(t *testing.T) {
cases := []struct {
lang, code, want string
}{
{"en", "pl", "Polish (niedziela.pl)"},
{"pl", "pl", "Polski (niedziela.pl)"},
{"en", "wuj", "Wujek (Polish)"},
{"pl", "wuj", "Wujek (pol.)"},
{"en", "vul", "Vulgate (Latin)"},
{"pl", "vul", "Wulgata (lac.)"},
{"en", "grb", "Greek"},
{"pl", "grb", "Grecki"},
{"en", "drb", "Douay-Rheims (English)"},
{"pl", "drb", "Douay-Rheims (ang.)"},
}
for _, c := range cases {
if got := Get(c.lang).Version[c.code]; got != c.want {
t.Errorf("Get(%q).Version[%q] = %q, want %q", c.lang, c.code, got, c.want)
}
}
}
func TestTUIStrings(t *testing.T) {
en := Get("en")
pl := Get("pl")
if en.FooterKeys != "tab/⇧tab version ←/→ day j/k scroll space/b page g/G top/bottom r refresh q quit" {
t.Errorf("en.FooterKeys = %q", en.FooterKeys)
}
if pl.FooterKeys != "tab/⇧tab wersja ←/→ dzień j/k przewiń spacja/b strona g/G góra/dół r odśwież q wyjście" {
t.Errorf("pl.FooterKeys = %q", pl.FooterKeys)
}
if en.Loading != "loading…" || pl.Loading != "ładowanie…" {
t.Errorf("Loading en=%q pl=%q", en.Loading, pl.Loading)
}
if en.NoReadingsFor != "no readings for " || pl.NoReadingsFor != "brak czytań na " {
t.Errorf("NoReadingsFor en=%q pl=%q", en.NoReadingsFor, pl.NoReadingsFor)
}
if en.ErrorPrefix != "error: " || pl.ErrorPrefix != "błąd: " {
t.Errorf("ErrorPrefix en=%q pl=%q", en.ErrorPrefix, pl.ErrorPrefix)
}
// Both carry exactly one trailing space: the TUI concatenates a date or
// error string directly onto them with no separator of its own (see
// internal/tui bodyLines: ui.NoReadingsFor+m.date, ui.ErrorPrefix+err).
if strings.HasSuffix(en.NoReadingsFor, " ") || strings.HasSuffix(pl.NoReadingsFor, " ") {
t.Errorf("NoReadingsFor has 2+ trailing spaces: en=%q pl=%q", en.NoReadingsFor, pl.NoReadingsFor)
}
if strings.HasSuffix(en.ErrorPrefix, " ") || strings.HasSuffix(pl.ErrorPrefix, " ") {
t.Errorf("ErrorPrefix has 2+ trailing spaces: en=%q pl=%q", en.ErrorPrefix, pl.ErrorPrefix)
}
if en.ErrorHint != "change date (←/→) or refresh (r)" || pl.ErrorHint != "zmień datę (←/→) lub odśwież (r)" {
t.Errorf("ErrorHint en=%q pl=%q", en.ErrorHint, pl.ErrorHint)
}
}
func TestBannerWords(t *testing.T) {
en := Get("en")
pl := Get("pl")
if en.BannerGospel != "Gospel" || pl.BannerGospel != "Ewangelia" {
t.Errorf("BannerGospel en=%q pl=%q", en.BannerGospel, pl.BannerGospel)
}
if en.BannerReadings != "Readings" || pl.BannerReadings != "Czytania" {
t.Errorf("BannerReadings en=%q pl=%q", en.BannerReadings, pl.BannerReadings)
}
if en.BannerConnective != "for" || pl.BannerConnective != "na" {
t.Errorf("BannerConnective en=%q pl=%q", en.BannerConnective, pl.BannerConnective)
}
}
// TestWebFragmentMessages covers the two web-only messages (interlinear
// "no verses" note, "no readings at all for this day" error fragment) that
// were unconditionally Polish before this fix.
func TestWebFragmentMessages(t *testing.T) {
en := Get("en")
pl := Get("pl")
if en.NoInterlinearVerses != "(no verses to align)" {
t.Errorf("en.NoInterlinearVerses = %q", en.NoInterlinearVerses)
}
if pl.NoInterlinearVerses != "(brak wersetów do zestawienia interlinearnego)" {
t.Errorf("pl.NoInterlinearVerses = %q", pl.NoInterlinearVerses)
}
if en.NoReadingsDay != "no readings for this day" {
t.Errorf("en.NoReadingsDay = %q", en.NoReadingsDay)
}
if pl.NoReadingsDay != "brak czytań na ten dzień" {
t.Errorf("pl.NoReadingsDay = %q", pl.NoReadingsDay)
}
}
// TestLookupFailureMessages covers render.GatherVersion/GatherVerses/
// resolveRef's four lookup/citation-failure templates.
func TestLookupFailureMessages(t *testing.T) {
en := Get("en")
pl := Get("pl")
cases := []struct {
name, en, pl string
}{
{"NoVersion", en.NoVersion, pl.NoVersion},
{"NoVersionPartial", en.NoVersionPartial, pl.NoVersionPartial},
{"NoReference", en.NoReference, pl.NoReference},
{"NoReferenceErr", en.NoReferenceErr, pl.NoReferenceErr},
}
want := map[string][2]string{
"NoVersion": {"(not in %s)", "(brak w „%s”)"},
"NoVersionPartial": {"(not in %s: %s)", "(brak w „%s”: %s)"},
"NoReference": {"(no reference)", "(brak odwołania)"},
"NoReferenceErr": {"(no reference: %v)", "(brak odwołania: %w)"},
}
for _, c := range cases {
w := want[c.name]
if c.en != w[0] {
t.Errorf("en.%s = %q, want %q", c.name, c.en, w[0])
}
if c.pl != w[1] {
t.Errorf("pl.%s = %q, want %q", c.name, c.pl, w[1])
}
}
}
func TestWebControlLabels(t *testing.T) {
en := Get("en")
pl := Get("pl")
cases := []struct {
name, en, pl string
}{
{"Lectionary", en.Lectionary, pl.Lectionary},
{"OptModern", en.OptModern, pl.OptModern},
{"OptTraditional", en.OptTraditional, pl.OptTraditional},
{"Parts", en.Parts, pl.Parts},
{"OptGospel", en.OptGospel, pl.OptGospel},
{"OptAll", en.OptAll, pl.OptAll},
{"Layout", en.Layout, pl.Layout},
{"OptHorizontal", en.OptHorizontal, pl.OptHorizontal},
{"OptColumns", en.OptColumns, pl.OptColumns},
{"OptInterlinear", en.OptInterlinear, pl.OptInterlinear},
{"Theme", en.Theme, pl.Theme},
{"Mono", en.Mono, pl.Mono},
}
want := map[string][2]string{
"Lectionary": {"lectionary", "lekcjonarz"},
"OptModern": {"modern", "nowy"},
"OptTraditional": {"traditional", "tradycyjny"},
"Parts": {"parts", "zakres"},
"OptGospel": {"Gospel", "Ewangelia"},
"OptAll": {"all parts", "wszystkie części"},
"Layout": {"layout", "układ"},
"OptHorizontal": {"horizontal", "poziomo"},
"OptColumns": {"columns", "kolumny"},
"OptInterlinear": {"interlinear", "interlinearnie"},
"Theme": {"theme", "motyw"},
"Mono": {"mono", "mono"},
}
for _, c := range cases {
w := want[c.name]
if c.en != w[0] {
t.Errorf("en.%s = %q, want %q", c.name, c.en, w[0])
}
if c.pl != w[1] {
t.Errorf("pl.%s = %q, want %q", c.name, c.pl, w[1])
}
}
}
func TestModernPartLabels(t *testing.T) {
en := Get("en")
pl := Get("pl")
want := map[string][2]string{
"pierwsze_czytanie": {"1. czytanie", "1st reading"},
"psalm": {"Psalm", "Psalm"},
"drugie_czytanie": {"2. czytanie", "2nd reading"},
"aklamacja": {"Aklamacja", "Acclamation"},
"ewangelia": {"Ewangelia", "Gospel"},
}
for partID, w := range want {
if got := pl.PartLabel[partID]; got != w[0] {
t.Errorf("pl.PartLabel[%q] = %q, want %q", partID, got, w[0])
}
if got := en.PartLabel[partID]; got != w[1] {
t.Errorf("en.PartLabel[%q] = %q, want %q", partID, got, w[1])
}
}
}
|