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
|
package app
import (
"slices"
"golang.org/x/text/collate"
"golang.org/x/text/language"
"git.thomasvoss.com/euro-cash.eu/src/i18n"
)
type country struct {
Code, Name string
}
var countryCodeToName = map[string]string{
"ad": "Andorra",
"at": "Austria",
"be": "Belgium",
/* TODO(2026): Add Bulgaria */
/* "bg": "Bulgaria", */
"cy": "Cyprus",
"de": "Germany",
"ee": "Estonia",
"es": "Spain",
"fi": "Finland",
"fr": "France",
"gr": "Greece",
"hr": "Croatia",
"ie": "Ireland",
"it": "Italy",
"lt": "Lithuania",
"lu": "Luxembourg",
"lv": "Latvia",
"mc": "Monaco",
"mt": "Malta",
"nl": "Netherlands",
"pt": "Portugal",
"si": "Slovenia",
"sk": "Slovakia",
"sm": "San Marino",
"va": "Vatican City",
}
func sortedCountries(p i18n.Printer) []country {
xs := []country{
{Code: "ad", Name: p.GetC("Andorra", "Place Name")},
{Code: "at", Name: p.GetC("Austria", "Place Name")},
{Code: "be", Name: p.GetC("Belgium", "Place Name")},
/* TODO(2026): Add Bulgaria */
/* {Code: "bg", Name: p.GetC("Bulgaria", "Place Name")}, */
{Code: "cy", Name: p.GetC("Cyprus", "Place Name")},
{Code: "de", Name: p.GetC("Germany", "Place Name")},
{Code: "ee", Name: p.GetC("Estonia", "Place Name")},
{Code: "es", Name: p.GetC("Spain", "Place Name")},
{Code: "fi", Name: p.GetC("Finland", "Place Name")},
{Code: "fr", Name: p.GetC("France", "Place Name")},
{Code: "gr", Name: p.GetC("Greece", "Place Name")},
{Code: "hr", Name: p.GetC("Croatia", "Place Name")},
{Code: "ie", Name: p.GetC("Ireland", "Place Name")},
{Code: "it", Name: p.GetC("Italy", "Place Name")},
{Code: "lt", Name: p.GetC("Lithuania", "Place Name")},
{Code: "lu", Name: p.GetC("Luxembourg", "Place Name")},
{Code: "lv", Name: p.GetC("Latvia", "Place Name")},
{Code: "mc", Name: p.GetC("Monaco", "Place Name")},
{Code: "mt", Name: p.GetC("Malta", "Place Name")},
{Code: "nl", Name: p.GetC("Netherlands", "Place Name")},
{Code: "pt", Name: p.GetC("Portugal", "Place Name")},
{Code: "si", Name: p.GetC("Slovenia", "Place Name")},
{Code: "sk", Name: p.GetC("Slovakia", "Place Name")},
{Code: "sm", Name: p.GetC("San Marino", "Place Name")},
{Code: "va", Name: p.GetC("Vatican City", "Place Name")},
}
c := collate.New(language.MustParse(p.Bcp))
slices.SortFunc(xs, func(x, y country) int {
return c.CompareString(x.Name, y.Name)
})
return xs
}
|