aboutsummaryrefslogtreecommitdiff
path: root/internal/i18n/vocab_test.go
blob: 97c09d67df81fa76eb6daaff42d87591830965a5 (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
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
package i18n

import (
	"testing"

	"github.com/lukaszkasprzak/lectio/internal/calendar"
)

// Every rank the calendar can emit must have a word in every shipped
// language. This is the guard against adding a constant later and silently
// rendering a raw key like "class-2" in the UI.
func TestVocabularyCoversEveryConstant(t *testing.T) {
	ranks := []calendar.Rank{
		calendar.RankFerial, calendar.RankOptional, calendar.RankMemorial,
		calendar.RankFeast, calendar.RankSolemnity,
		calendar.RankClass1, calendar.RankClass2, calendar.RankClass3,
		calendar.RankClass4, calendar.RankCommemoration,
	}
	for _, lang := range []string{"en", "pl"} {
		ui := Get(lang)
		for _, r := range ranks {
			if ui.Rank[string(r)] == "" {
				t.Errorf("%s: no rank word for %q", lang, r)
			}
		}
	}
}

// The English rank words must not change: lectio's CLI has printed these since
// before the table existed, and English users' output should be untouched.
func TestEnglishRankWordingUnchanged(t *testing.T) {
	want := map[string]string{
		"solemnity": "solemnity", "feast": "feast", "memorial": "memorial",
		"optional": "optional memorial", "ferial": "feria",
		"class-1": "I class", "class-2": "II class",
		"class-3": "III class", "class-4": "IV class",
		"commemoration": "commemoration",
	}
	ui := Get("en")
	for k, v := range want {
		if got := ui.Rank[k]; got != v {
			t.Errorf("rank[%q] = %q, want %q", k, got, v)
		}
	}
}

// The Polish rank words must be exactly this spelling, diacritics included:
// TestVocabularyCoversEveryConstant only checks non-emptiness, so a typo
// (e.g. "uroczystosc" for "uroczystość", or a wrong diacritic) would pass
// silently without this pin. Polish correctness is the whole point of this
// project.
func TestPolishRankWordingUnchanged(t *testing.T) {
	want := map[string]string{
		"solemnity": "uroczystość", "feast": "święto",
		"memorial": "wspomnienie obowiązkowe", "optional": "wspomnienie dowolne",
		"ferial":  "dzień powszedni",
		"class-1": "I klasy", "class-2": "II klasy",
		"class-3": "III klasy", "class-4": "IV klasy",
		"commemoration": "komemoracja",
	}
	ui := Get("pl")
	for k, v := range want {
		if got := ui.Rank[k]; got != v {
			t.Errorf("rank[%q] = %q, want %q", k, got, v)
		}
	}
}

// The Polish part labels must be exactly this spelling, diacritics included,
// and no others. This asserts against plUI directly, NOT i18n.Get("pl"):
// Get overlays the embedded English baseline first and then the Polish file
// on top (lang.go's Get), so a label present in English and missing only
// from plUI.PartLabel would resolve through Get("pl") to the identical
// English word rather than "" -- invisible to
// internal/readings/partids_test.go's TestEveryPartIDHasLabels, which only
// checks Get(lang) for non-emptiness. plUI is the unmerged golden source
// with no fallback, so a missing entry is genuinely absent there, which is
// the only way to catch this. The exact key-count check guards against a
// future addition to plUI.PartLabel slipping in unpinned.
func TestPolishPartLabelWordingUnchanged(t *testing.T) {
	want := map[string]string{
		"pierwsze_czytanie": "1. czytanie",
		"psalm":             "Psalm",
		"drugie_czytanie":   "2. czytanie",
		"aklamacja":         "Aklamacja",
		"ewangelia":         "Ewangelia",
		"epistola":          "Lekcja",
		"evangelium":        "Ewangelia",
	}
	if len(plUI.PartLabel) != len(want) {
		t.Fatalf("plUI.PartLabel has %d keys, want %d: %v", len(plUI.PartLabel), len(want), plUI.PartLabel)
	}
	for k, v := range want {
		if got, ok := plUI.PartLabel[k]; !ok || got != v {
			t.Errorf("plUI.PartLabel[%q] = %q (present=%v), want %q", k, got, ok, v)
		}
	}
}