-
Notifications
You must be signed in to change notification settings - Fork 0
/
translator.go
220 lines (213 loc) · 6.61 KB
/
translator.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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
package main
import (
"fmt"
"net/http"
"github.com/gorilla/csrf"
"github.com/nicksnyder/go-i18n/v2/i18n"
)
type templateVars map[string]interface{}
type pageInfo struct {
convention convention
email string
localizer *i18n.Localizer
r *http.Request
stripeSessionID string
}
func getVars(i *pageInfo) templateVars {
btnCompletePayment := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "btnCompletePayment",
Other: "Complete payment to Register",
},
})
btnSendVerifEmail := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "btnSendVerifEmail",
Other: "Send verification email",
},
})
btnContinueToCheckout := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "btnContinueToCheckout",
Other: "Continue to checkout",
},
})
errProcessPayment := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "errProcessPayment",
Other: "Could not process payment",
},
})
frmAmount := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmAmount",
Other: "Amount {{ .CostPrint }} {{ .Currency }}",
},
TemplateData: map[string]string{
"CostPrint": fmt.Sprintf("%d", i.convention.Cost/100),
"Currency": i.convention.Currency_Code,
},
})
frmCity := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmCity",
Other: "City",
},
})
frmCountry := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmCountry",
Other: "Country",
},
})
frmEnterEmail := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmEnterEmail",
Other: "Please enter your email address",
},
})
frmFirstName := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmFirstName",
Other: "First name",
},
})
frmILiveIn := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmILiveIn",
Other: "I live in...",
},
})
frmPaymentDetails := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmPaymentDetails",
Other: "Payment Details",
},
})
frmSameEmail := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmSameEmail",
Other: "Email - use the same one you verified with",
},
})
frmYourDetails := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmYourDetails",
Other: "Your details",
},
})
frmWhoAreYou := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmWhoAreYou",
Other: "Who are you? Member of AA, Al-Anon or Guest?",
},
})
frmWillingService := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmWillingService",
Other: "Are you willing to be of service at the convention?",
},
})
frmHelpOutreach := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmHelpOutreach",
Other: "Do you want to help outreach the convention?",
},
})
frmGetTshirt := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "frmGetTshirt",
Other: "Would you be interested to get convention T-shirts?",
},
})
pgCheckEmail := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "pgCheckEmail",
Other: "Please check your email inbox, and click the link we've sent you",
},
})
pgNowRegistered := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "pgNowRegistered",
Other: "You are now registered!",
},
})
pgRegisterFor := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "pgRegisterFor",
Other: "Register for {{ .Name }}",
},
TemplateData: map[string]string{
"Name": i.convention.Name,
},
})
pgRegisteredFor := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "pgRegisteredFor",
Other: "Registered for {{ .Name }}",
},
TemplateData: map[string]string{
"Name": i.convention.Name,
},
})
valEnterEmail := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "valEnterEmail",
Other: "Please enter a valid email address so we can send you convention details.",
},
})
valFirstName := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "valFirstName",
Other: "Valid first name is required.",
},
})
valSameEmail := i.localizer.MustLocalize(&i18n.LocalizeConfig{
DefaultMessage: &i18n.Message{
ID: "valSameEmail",
Other: "Please enter a valid email address so we can send you convention details.",
},
})
return map[string]interface{}{
"btnCompletePayment": btnCompletePayment,
"btnContinueToCheckout": btnContinueToCheckout,
"btnSendVerifEmail": btnSendVerifEmail,
"errProcessPayment": errProcessPayment,
"frmAmount": frmAmount,
"frmCity": frmCity,
"frmCountry": frmCountry,
"frmEnterEmail": frmEnterEmail,
"frmFirstName": frmFirstName,
"frmILiveIn": frmILiveIn,
"frmPaymentDetails": frmPaymentDetails,
"frmSameEmail": frmSameEmail,
"frmYourDetails": frmYourDetails,
"frmWhoAreYou": frmWhoAreYou,
"frmWillingService": frmWillingService,
"frmHelpOutreach": frmHelpOutreach,
"frmGetTshirt": frmGetTshirt,
"pgCheckEmail": pgCheckEmail,
"pgNowRegistered": pgNowRegistered,
"pgRegisterFor": pgRegisterFor,
"pgRegisteredFor": pgRegisteredFor,
"valEnterEmail": valEnterEmail,
"valFirstName": valFirstName,
"valSameEmail": valSameEmail,
"Name": i.convention.Name,
"Cost": i.convention.Cost,
"CostPrint": i.convention.Cost / 100,
"Currency": i.convention.Currency_Code,
"Year": i.convention.Year,
"City": i.convention.City,
"Country": i.convention.Country,
"Countries": Countries,
"Fellowships": Fellowships,
"Willings": Willings,
"HelpOutreaches": HelpOutreaches,
"Tshirts": Tshirts,
"Key": stripePublishableKey,
csrf.TemplateTag: csrf.TemplateField(i.r),
"Email": i.email,
"StripeSessionID": i.stripeSessionID,
}
}