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 lib
import (
"slices"
"golang.org/x/text/collate"
"golang.org/x/text/language"
)
type Country struct {
Code, Name string
}
func SortedCountries(p Printer) []Country {
xs := []Country{
{Code: "ad", Name: p.T("Andorra")},
{Code: "at", Name: p.T("Austria")},
{Code: "be", Name: p.T("Belgium")},
{Code: "cy", Name: p.T("Cyprus")},
{Code: "de", Name: p.T("Germany")},
{Code: "ee", Name: p.T("Estonia")},
{Code: "es", Name: p.T("Spain")},
{Code: "fi", Name: p.T("Finland")},
{Code: "fr", Name: p.T("France")},
{Code: "gr", Name: p.T("Greece")},
{Code: "hr", Name: p.T("Croatia")},
{Code: "ie", Name: p.T("Ireland")},
{Code: "it", Name: p.T("Italy")},
{Code: "lt", Name: p.T("Lithuania")},
{Code: "lu", Name: p.T("Luxembourg")},
{Code: "lv", Name: p.T("Latvia")},
{Code: "mc", Name: p.T("Monaco")},
{Code: "mt", Name: p.T("Malta")},
{Code: "nl", Name: p.T("Netherlands")},
{Code: "pt", Name: p.T("Portugal")},
{Code: "si", Name: p.T("Slovenia")},
{Code: "sk", Name: p.T("Slovakia")},
{Code: "sm", Name: p.T("San Marino")},
{Code: "va", Name: p.T("Vatican City")},
}
c := collate.New(language.MustParse(p.Locale.Bcp))
slices.SortFunc(xs, func(x, y Country) int {
return c.CompareString(x.Name, y.Name)
})
return xs
}
|