tools: align locale diagnostics and generate native language names
Validate / Validate (push) Successful in 2m46s
Validate / Validate (push) Successful in 2m46s
This commit is contained in:
1 parent
b8089e8a7e
commit
d99c5d1dc5
13 files changed
+170
-46
No files matched your search
@@ -0,0 +1,33 @@
|
||||
package preview
|
||||
|
||||
import (
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
"gitea-mail-templates/tools/upstream"
|
||||
)
|
||||
|
||||
func TestNativeLanguageNames(t *testing.T) {
|
||||
snapshot, err := upstream.LoadPinned(filepath.Join("..", ".."))
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
locales := snapshot.Languages()
|
||||
names := languageNames(locales)
|
||||
if len(names) != len(locales) {
|
||||
t.Fatal("language names do not match preview locales")
|
||||
}
|
||||
for _, locale := range locales {
|
||||
if names[locale] == "" || names[locale] == locale {
|
||||
t.Errorf("missing native name for %s", locale)
|
||||
}
|
||||
}
|
||||
for locale, want := range map[string]string{"ga-IE": "Gaeilge", "is-IS": "íslenska"} {
|
||||
if names[locale] != want {
|
||||
t.Errorf("%s: got %q, want %q", locale, names[locale], want)
|
||||
}
|
||||
}
|
||||
if got := languageNames([]string{"!invalid"})["!invalid"]; got != "!invalid" {
|
||||
t.Fatalf("invalid locale fallback: %q", got)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user