6
6
"os"
7
7
"path/filepath"
8
8
"testing"
9
-
10
- "github.com/nicksnyder/go-i18n/v2/i18n"
11
9
)
12
10
13
11
func TestExtract (t * testing.T ) {
@@ -16,14 +14,12 @@ func TestExtract(t *testing.T) {
16
14
name string
17
15
fileName string
18
16
file string
19
- messages []* i18n.Message
20
17
activeFile []byte
21
18
}{
22
19
{
23
20
name : "no translations" ,
24
21
fileName : "file.go" ,
25
22
file : `package main` ,
26
- messages : nil ,
27
23
},
28
24
{
29
25
name : "global declaration" ,
@@ -36,11 +32,26 @@ func TestExtract(t *testing.T) {
36
32
ID: "Plural ID",
37
33
}
38
34
` ,
39
- messages : []* i18n.Message {
40
- {
41
- ID : "Plural ID" ,
42
- },
43
- },
35
+ },
36
+ {
37
+ name : "escape" ,
38
+ fileName : "file.go" ,
39
+ file : `package main
40
+
41
+ import "github.com/nicksnyder/go-i18n/v2/i18n"
42
+
43
+ var a = &i18n.Message{
44
+ ID: "a",
45
+ Other: "a \" b",
46
+ }
47
+ var b = &i18n.Message{
48
+ ID: "b",
49
+ Other: ` + "`" + `a " b` + "`" + `,
50
+ }
51
+ ` ,
52
+ activeFile : []byte (`a = "a \" b"
53
+ b = "a \" b"
54
+ ` ),
44
55
},
45
56
{
46
57
name : "no extract from test" ,
@@ -55,11 +66,6 @@ func TestExtract(t *testing.T) {
55
66
l.Localize(&i18n.LocalizeConfig{MessageID: "Plural ID"})
56
67
}
57
68
` ,
58
- messages : []* i18n.Message {
59
- {
60
- ID : "Plural ID" ,
61
- },
62
- },
63
69
},
64
70
{
65
71
name : "must short form id only" ,
@@ -74,11 +80,6 @@ func TestExtract(t *testing.T) {
74
80
l.MustLocalize(&i18n.LocalizeConfig{MessageID: "Plural ID"})
75
81
}
76
82
` ,
77
- messages : []* i18n.Message {
78
- {
79
- ID : "Plural ID" ,
80
- },
81
- },
82
83
},
83
84
{
84
85
name : "custom package name" ,
@@ -93,11 +94,6 @@ func TestExtract(t *testing.T) {
93
94
}
94
95
}
95
96
` ,
96
- messages : []* i18n.Message {
97
- {
98
- ID : "Plural ID" ,
99
- },
100
- },
101
97
},
102
98
{
103
99
name : "exhaustive plural translation" ,
@@ -119,18 +115,6 @@ func TestExtract(t *testing.T) {
119
115
}
120
116
}
121
117
` ,
122
- messages : []* i18n.Message {
123
- {
124
- ID : "Plural ID" ,
125
- Description : "Plural description" ,
126
- Zero : "Zero translation" ,
127
- One : "One translation" ,
128
- Two : "Two translation" ,
129
- Few : "Few translation" ,
130
- Many : "Many translation" ,
131
- Other : "Other translation" ,
132
- },
133
- },
134
118
activeFile : []byte (`["Plural ID"]
135
119
description = "Plural description"
136
120
few = "Few translation"
@@ -156,11 +140,6 @@ zero = "Zero translation"
156
140
}
157
141
}
158
142
` ,
159
- messages : []* i18n.Message {
160
- {
161
- ID : "Plural ID" ,
162
- },
163
- },
164
143
},
165
144
}
166
145
0 commit comments