generated from snivilised/astrolib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
li18ngo-suite_test.go
56 lines (48 loc) · 1.34 KB
/
li18ngo-suite_test.go
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
package li18ngo_test
import (
"testing"
. "github.com/onsi/ginkgo/v2" //nolint:revive // ok
. "github.com/onsi/gomega" //nolint:revive // ok
"github.com/snivilised/li18ngo"
"github.com/snivilised/li18ngo/internal/translate"
"github.com/snivilised/li18ngo/locale"
"golang.org/x/text/language"
)
func TestLi18ngo(t *testing.T) {
RegisterFailHandler(Fail)
RunSpecs(t, "Li18ngo Suite")
}
type textTE struct {
message string
path string
sourcePath string
name string
defaultAcceptable bool
}
const (
expectUS = "Found graffiti on sidewalk; primary color: 'Violet'"
expectGB = "Found graffiti on pavement; primary colour: 'Violet'"
)
func testTranslationPath(entry *textTE) string {
// this test form required, because DescribeTable can't be used
// due to not being able to setup state correctly, eg l10nPath
//
if err := li18ngo.Use(func(o *translate.UseOptions) {
o.Tag = language.AmericanEnglish
o.DefaultIsAcceptable = entry.defaultAcceptable
o.From = translate.LoadFrom{
Path: entry.path,
Sources: translate.TranslationFiles{
locale.TestGrafficoSourceID: translate.TranslationSource{
Path: entry.sourcePath,
Name: "test.graffico",
},
},
}
}); err != nil {
Fail(err.Error())
}
return li18ngo.Text(PavementGraffitiReportTemplData{
Primary: "Violet",
})
}