summaryrefslogtreecommitdiffhomepage
path: root/lib/countries.go
diff options
context:
space:
mode:
Diffstat (limited to 'lib/countries.go')
-rw-r--r--lib/countries.go46
1 files changed, 46 insertions, 0 deletions
diff --git a/lib/countries.go b/lib/countries.go
new file mode 100644
index 0000000..565f61c
--- /dev/null
+++ b/lib/countries.go
@@ -0,0 +1,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
+}