/
localization.go
478 lines (449 loc) · 18.5 KB
/
localization.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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
package marketplace
import (
"encoding/json"
"io/ioutil"
"strings"
"time"
"github.com/bobanderson-malibu/dotfree/dot-free-market/modules/util"
)
var localizationMap map[string]Localization
var vendorshipAgreementMap map[string]string
type LocalizationLayout struct {
BTCRates string `json:"btcrates"`
BuyerGuide string `json:"buyerguide"`
Help string `json:"help"`
Language string `json:"language"`
Login string `json:"login"`
Marketplace string `json:"marketplace"`
Messageboard string `json:"messageboard"`
MyProfile string `json:"myprofile"`
PremiumAd string `json:"premiumad"`
Register string `json:"register"`
Rules string `json:"rules"`
Sections string `json:"sections"`
Settings string `json:"settings"`
Support string `json:"support"`
Tochka string `json:"tochka"`
VendorGuide string `json:"vendorguide"`
Vendors string `json:"vendors"`
Wallet string `json:"wallet"`
}
type LocaliztionUserCard struct {
Registred string `json:"registred"`
LastSeen string `json:"lastseen"`
PossibleScammer string `json:"possiblescammer"`
Staff string `json:"staff"`
Vendor string `json:"vendor"`
PremiumVendor string `json:"premiumvendor"`
TrustedSeller string `json:"trustedseller"`
Tester string `json:"tester"`
Buyer string `json:"buyer"`
NoReviewsYet string `json:"noreviewsyet"`
}
type LocalizationLeftMenu struct {
About string `json:"about"`
Account string `json:"account"`
Board string `json:"board"`
Feed string `json:"feed"`
News string `json:"news"`
Invitations string `json:"invitations"`
Items string `json:"items"`
Orders string `json:"orders"`
PM string `json:"pm"`
PMs string `json:"pms"`
Referrals string `json:"referrals"`
Reviews string `json:"reviews"`
Support string `json:"support"`
VendorInfo string `json:"vendorinfo"`
SignOut string `json:"signout"`
Shoutbox string `json:"shoutbox"`
Disputes string `json:"disputes"`
Warnings string `json:"warnings"`
}
type LocalizationFeed struct {
FullDiscussion string `json:"fulldiscussion"`
All string `json:"all"`
}
type LocalizationOrders struct {
Amount string `json:"amount"`
BTCAddress string `json:"btcaddress"`
Buyer string `json:"buyer"`
BuyerPublicKey string `json:"buyerpublickey"`
Cancel string `json:"cancel"`
CancelDescription string `json:"canceldescription"`
Comment string `json:"comment"`
CreatedAt string `json:"createdat"`
Currency string `json:"currency"`
CurrentAmount string `json:"currentamount"`
CurrentStatus string `json:"currentstatus"`
Date string `json:"date"`
Description string `json:"description"`
Dispute string `json:"dispute"`
DisputeReason string `json:"disputereason"`
DropCoordinates string `json:"dropcoordinates"`
FEDescription string `json:"fedescription"`
Finalize string `json:"finalize"`
FundsWillBeReleased string `json:"fundswillbereleased"`
Image string `json:"image"`
IsReviewed string `json:"isreviewed"`
Item string `json:"item"`
MarkDispatched string `json:"markdispatched"`
MarketPrivateKey string `json:"marketprivatekey"`
MarketPublicKey string `json:"marketpublickey"`
MarkShipped string `json:"markshipped"`
Next string `json:"next"`
NoOrders string `json:"noorders"`
NoOrdersDescription string `json:"noordersdescription"`
NumberOfMessages string `json:"numberofmessages"`
Package string `json:"package"`
PaymentDetails string `json:"paymentdetails"`
PayViaEscrow string `json:"payviaescrow"`
PayViaMultisig string `json:"payviamultisig"`
PurchaseDetails string `json:"purchasedetails"`
QRCode string `json:"qrcode"`
SellerPublicKey string `json:"sellerpublickey"`
ShippingDetails string `json:"shippingdetails"`
StartDispute string `json:"startdispute"`
Status string `json:"status"`
StatusHistory string `json:"statushistory"`
TransactionIsCancelled string `json:"transactioniscancelled"`
Vendor string `json:"vendor"`
}
type LocalizationMessageboard struct {
BackToAll string `json:"backtoall"`
Captcha string `json:"captcha"`
Chat string `json:"chat"`
CreatedBy string `json:"createdby"`
CreateNewThread string `json:"createnewthread"`
Error string `json:"error"`
General string `json:"general"`
Image string `json:"image"`
LastUpdated string `json:"lastupdated"`
Message string `json:"message"`
NoMessages string `json:"nomessages"`
NoMessagesDescription string `json:"nomessagesdescription"`
NumberOfMessages string `json:"numberofmessages"`
Reply string `json:"reply"`
Sections string `json:"sections"`
Support string `json:"support"`
Vendors string `json:"vendors"`
Section string `json:"section"`
Title string `json:"title"`
Text string `json:"text"`
Save string `json:"save"`
NewThread string `json:"newthread"`
EditThread string `json:"editthread"`
FixProblem string `json:"fixproblem"`
}
type LocalizationRating struct {
Error string `json:"error"`
Review string `json:"review"`
Header string `json:"header"`
ItemRating string `json:"itemrating"`
ItemReview string `json:"itemreview"`
MarketplaceRating string `json:"marketplacerating"`
MarketplaceReview string `json:"marketplacereview"`
SellerRating string `json:"sellerrating"`
SellerReview string `json:"sellerreview"`
Save string `json:"save"`
}
type LocalizationReferrals struct {
ReferralLink string `json:"referrallink"`
NumberOfInvitedUsers string `json:"numberofinvitedusers"`
}
type LocalizationAboutStore struct {
Staff string `json:"staff"`
About string `json:"about"`
Statistics string `json:"statistics"`
Agreement string `json:"agreement"`
ContactInformation string `json:"contactinformation"`
AboutEmpty string `json:"aboutempty"`
AboutEmptyDescription string `json:"aboutemptydescription"`
ShippingOptions string `json:"shippingoptions"`
Name string `json:"name"`
PriceUSD string `json:"priceusd"`
}
type LocalizationAboutUser struct {
About string `json:"about"`
Statistics string `json:"statistics"`
ContactInformation string `json:"contactinformation"`
AboutEmpty string `json:"aboutempty"`
AboutEmptyDescription string `json:"aboutemptydescription"`
}
type LocalizationAuth struct {
Username string `json:"username"`
Passphrase string `json:"passphrase"`
RepeatPassphrase string `json:"repeatpassphrase"`
InviteCode string `json:"invitecode"`
InviteCodeDescription string `json:"invitecodedescription"`
Buyer string `json:"buyer"`
Vendor string `json:"vendor"`
Captcha string `json:"captcha"`
Login string `json:"login"`
Register string `json:"register"`
LoginWithPGP string `json:"loginwithpgp"`
Error string `json:"error"`
EncryptedMessage string `json:"encryptedmessage"`
EncryptedMessageDescription string `json:"encryptedmessagedescription"`
DecryptedMessage string `json:"decryptedmessage"`
UsernameDescription string `json:"usernamedescription"`
PassphraseDescription string `json:"passphrasedescription"`
VerifyAccount string `json:"verifyaccount"`
MyAccount string `json:"myaccount"`
}
type LocalizationItems struct {
About string `json:"about"`
AddItem string `json:"additem"`
AddPackage string `json:"addpackage"`
AllCountries string `json:"allcountries"`
AllTypes string `json:"alltypes"`
Categories string `json:"categories"`
Category string `json:"category"`
City string `json:"city"`
Currency string `json:"currency"`
DateAdded string `json:"dateadded"`
Delete string `json:"delete"`
DeleteItem string `json:"deleteitem"`
DeliveryType string `json:"deliverytype"`
Description string `json:"description"`
Digital string `json:"digital"`
Drop string `json:"drop"`
DropPreorder string `json:"droppreorder"`
Duplicate string `json:"duplicate"`
Edit string `json:"edit"`
EditItem string `json:"edititem"`
EditPackages string `json:"editpackages"`
Error string `json:"error"`
Filters string `json:"filters"`
ResetFilters string `json:"ResetFilters"`
Image string `json:"image"`
LookingFor string `json:"lookingfor"`
Mail string `json:"mail"`
Name string `json:"name"`
Next string `json:"next"`
NoItems string `json:"noitems"`
NoReviews string `json:"noreviews"`
OutOfStock string `json:"outofstock"`
PackageName string `json:"packagename"`
Popularity string `json:"popularity"`
Price string `json:"price"`
PriceBTC string `json:"pricebtc"`
Purchase string `json:"purchase"`
Rating string `json:"rating"`
Reviews string `json:"reviews"`
Save string `json:"save"`
Search string `json:"search"`
ShippingFrom string `json:"shippingfrom"`
ShippingTo string `json:"shippingto"`
SortBy string `json:"sortby"`
Subcategory string `json:"subcategory"`
Type string `json:"type"`
SalesAmount string `json:"salesamount"`
SalesVolume string `json:"salesvolume"`
}
type LocalizationSettings struct {
About string `json:"about"`
Account string `json:"account"`
AboutDescription string `json:"aboutdescription"`
Avatar string `json:"avatar"`
AvatarDescription string `json:"avatardescription"`
BTCAddressChangeHistory string `json:"btcaddresschangehistory"`
BTCWallet string `json:"btcwallet"`
BTCWalletDescription string `json:"btcwalletdescription"`
BTCMultisigPublicKey string `json:"btcmultisigpublickey"`
BTCMultisigPublicKeyDescription string `json:"btcmultisigpublickeydescription"`
Contacts string `json:"contacts"`
DecriptedText string `json:"decriptedtext"`
DecriptText string `json:"decripttext"`
Enable2FA string `json:"enable2fa"`
Encryption string `json:"encryption"`
Error string `json:"error"`
Off string `json:"off"`
On string `json:"on"`
Payments string `json:"payments"`
PGPPublicKey string `json:"pgppublickey"`
Profile string `json:"profile"`
Save string `json:"save"`
SetupPGPKey string `json:"setuppgpkey"`
ShortDescription string `json:"shortdescription"`
ShortDescriptionDescription string `json:"shortdescriptiondescription"`
TwoFactorAuthentication string `json:"twofactorauthentication"`
TwoFactorAuthenticationDescription string `json:"twofactorauthenticationdescription"`
Username string `json:"username"`
VendorSettings string `json:"vendorsettings"`
ShippingSettings string `json:"shippingsettings"`
Name string `json:"name"`
Price string `json:"price"`
Add string `json:"add"`
VacationMode string `json:"vacationmode"`
VacationModeDescription string `json:"vacationmodedescription"`
Password string `json:"password"`
ChangePassword string `json:"changepassword"`
OldPassword string `json:"oldpassword"`
NewPassword string `json:"newpassword"`
RepeatNewPassword string `json:"repeatnewpassword"`
}
type LocalizationWallet struct {
RecieveBitcoins string `json:"recievebitcoins"`
SendBitcoins string `json:"sendbitcoins"`
BTCAddress string `json:"btcaddress"`
QRCode string `json:"qrcode"`
Balance string `json:"balance"`
AmountToSend string `json:"amounttosend"`
Send string `json:"send"`
UnconfirmedBalance string `json:"unconfirmedbalance"`
Time string `json:"time"`
Action string `json:"action"`
Address string `json:"address"`
Actions string `json:"actions"`
}
type LocalizationIndex struct {
WelcomeToTochka string `json:"welcometotochka"`
WelcomeToTochkaDescription string `json:"welcometotochkadescription"`
EscrowAndMultisig string `json:"escrowandmultisig"`
EscrowAndMultisigDescription string `json:"escrowandmultisigdescription"`
ActiveCommunity string `json:"activecommunity"`
ActiveCommunityDescription string `json:"activecommunitydescription"`
Support string `json:"support"`
SupportDescription string `json:"supportdescription"`
Vendors string `json:"vendors"`
VendorsDescription string `json:"vendorsdescription"`
Referrals string `json:"referrals"`
ReferralsDescription string `json:"referralsdescription"`
}
type LocalizationDispute struct {
AddClaim string `json:"addclaim"`
Claim string `json:"claim"`
Claims string `json:"claims"`
Dispute string `json:"dispute"`
Disputes string `json:"disputes"`
NoDisputes string `json:"nodisputes"`
NoDisputesDescription string `json:"nodisputesdescription"`
}
type LocalizationStaff struct {
Staff string `json:"staff"`
Support string `json:"support"`
Items string `json:"items"`
Disputes string `json:"disputes"`
Messageboard string `json:"messageboard"`
Actions string `json:"actions"`
Statistics string `json:"statistics"`
}
type Localization struct {
AboutStore LocalizationAboutStore `json:"aboutstore"`
AboutUser LocalizationAboutUser `json:"aboutuser"`
Auth LocalizationAuth `json:"auth"`
Feed LocalizationFeed `json:"feed"`
Items LocalizationItems `json:"items"`
Layout LocalizationLayout `json:"layout"`
LeftMenu LocalizationLeftMenu `json:"leftmenu"`
Messageboard LocalizationMessageboard `json:"messageboard"`
Orders LocalizationOrders `json:"orders"`
Rating LocalizationRating `json:"rating"`
Referrals LocalizationReferrals `json:"referrals"`
Settings LocalizationSettings `json:"settings"`
UserCard LocaliztionUserCard `json:"usercard"`
Wallet LocalizationWallet `json:"wallet"`
Index LocalizationIndex `json:"index"`
Dispute LocalizationDispute `json:"dispute"`
Staff LocalizationStaff `json:"staff"`
Verification LocalizationVerification `json:"verification"`
Greeting string `json:"greeting"`
TrustedVendor string `json:"trustedvendor"`
}
type LocalizationVerification struct {
Encryption string
EncryptionDescription string
VendorshipAgreement string
VendorshipAgreementDescription string
VendorshipAgreementInstructions string
MembershipPlans string
MembershipPlansDescription string
Verification string
VerificationDescription string
VerificationInstructions string
AgreementText string
SignedAgreement string
}
func TranslateFeedActions(str, lang string) string {
if lang == "ru" {
if str == "added new item" {
str = "добавил новый товар"
}
if str == "created new thread" {
str = "создал новую тему"
}
}
if lang == "de" {
if str == "added new item" {
str = "erstellt"
}
if str == "created new thread" {
str = "erstellt einen neuen thread"
}
}
if lang == "es" {
if str == "added new item" {
str = "nuevo elemento creado"
}
if str == "created new thread" {
str = "creado un nuevo hilo"
}
}
if lang == "fr" {
if str == "added new item" {
str = "créé un nouvel élément"
}
if str == "created new thread" {
str = "créé un nouveau fil"
}
}
return str
}
func GetLocalization(lang string) Localization {
if l, ok := localizationMap[lang]; ok {
return l
} else {
return localizationMap["en"]
}
}
func ReadLocalizationFile(file string) Localization {
l := Localization{}
path := util.GetFileAbsolutePath("./data/i18n/" + file)
raw, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
json.Unmarshal(raw, &l)
return l
}
func ReadVendorshipAgreement(language string) string {
path := util.GetFileAbsolutePath("./data/i18n/" + language + "_vendorship_agreement.txt")
raw, err := ioutil.ReadFile(path)
if err != nil {
panic(err)
}
return string(raw[:])
}
func GetVendorshipAgreement(lang string, user User, dt time.Time) string {
agreement := vendorshipAgreementMap["en"]
agreement = strings.Replace(agreement, "{fingerprint}", user.Fingerprint(), -1)
agreement = strings.Replace(agreement, "{username}", user.Username, -1)
agreement = strings.Replace(agreement, "{date}", dt.Format("2006-01-02"), -1)
return agreement
}
func init() {
localizationMap = map[string]Localization{
"rs": ReadLocalizationFile("RS.json"),
"ru": ReadLocalizationFile("RU.json"),
"fr": ReadLocalizationFile("FR.json"),
"de": ReadLocalizationFile("DE.json"),
"es": ReadLocalizationFile("ES.json"),
"en": ReadLocalizationFile("EN.json"),
"tr": ReadLocalizationFile("TR.json"),
"it": ReadLocalizationFile("IT.json"),
}
vendorshipAgreementMap = map[string]string{
"en": ReadVendorshipAgreement("EN"),
}
}