/
model.go
293 lines (256 loc) · 10.4 KB
/
model.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
package crowdin
// AddFileOptions used for AddFile() API call
type AddFileOptions struct {
// Note: Used only when uploading CSV (or XLS/XLSX) file to define data columns mapping.
// Acceptable value is the combination of the following constants:
// "identifier" — Column contains string identifier.
// "source_phrase" — Column contains only source string (in result string will contain same string).
// "source_or_translation" — Column contains source string but when exporting same column should contain translation (also when uploading existing translations, the value from this column will be used as a translated string).
// "translation" — Column contains translated string (when imported file already contains translations).
// "context" — Column contains some comments on source string. Context information.
// "max_length" — Column contains max. length of translation for this string.
// "none" — Do not import column.
Scheme string
// Used when uploading CSV (or XLS/XLSX) files via API. Defines whether first line should be imported or it contains columns headers. May not contain value.
FirstLineContainsHeader bool
// Files array that should be added to Crowdin project. Array keys should contain file names with path in Crowdin project.
Files map[string]string
// Acceptable values are:
// empty value or "auto" — Try to detect file type by extension or MIME type
// "gettext" — GNU GetText (*.po, *.pot)
// "qtts" — Nokia Qt (*.ts)
// "dklang" — Delphi DKLang (*.dklang)
// "android" — Android (*.xml)
// "resx" — .NET (*.resx)
// "properties" — Java (*.properties)
// "macosx" — Mac OS X / iOS (*.strings)
// "blackberry" — BlackBerry (*.rrc)
// "Symbian" — Symbian (*.lXX)
// "flex" — Adobe Flex (*.properties)
// "bada" — Samsung Bada (*.xml)
// "txt" — Plain Text (*.txt)
// "srt" — SubRip .srt (*.srt)
// "sbv" — Youtube .sbv (*.sbv)
// "xliff" — XLIFF (*.xliff)
// "html" — HTML (*.html, *.htm, *.xhtml, *.xhtm)
// "dtd" — Mozilla DTD (*.dtd)
// "chrome" — Google Chrome Extension (*.json)
// "yaml" — Ruby On Rails (*.yaml)
// "csv" — Comma Separated Values (*.csv)
// "rc" — Windows Resources (*.rc)
// "wxl" — WiX Installer Resources (*.wxl)
// "nsh" — NSIS Installer Resources (*.nsh)
// "joomla" — Joomla localizable resources (*.ini)
// "ini" — Generic INI (*.ini)
// "isl" — ISL (*.isl)
// "resw" — Windows 8 Metro (*.resw)
// "resjson" — Windows 8 Metro (*.resjson)
// "docx" — Microsoft Office and OpenOffice.org Documents (*.docx, *.dotx, *.odt, *.ott, *.xslx, *.xltx, *.pptx, *.potx, *.ods, *.ots, *.odg, *.otg, *.odp, *.otp, *.idml)
// "md" — Markdown (*.md, *.text, *.markdown...)
// "mediawiki" — MediaWiki (*.wiki, *.wikitext, *.mediawiki)
// "play" — Play Framework
// "haml" — Haml (*.haml)
// "arb" — Application Resource Bundle (*.arb)
// "vtt" — Video Subtitling and WebVTT (*.vtt)
Type string
}
// UpdateFileOptions used for UpdateFile() API call
type UpdateFileOptions struct {
// Note: Used only when uploading CSV (or XLS/XLSX) file to define data columns mapping.
// Acceptable value is the combination of the following constants:
// "identifier" — Column contains string identifier.
// "source_phrase" — Column contains only source string (in result string will contain same string).
// "source_or_translation" — Column contains source string but when exporting same column should contain translation (also when uploading existing translations, the value from this column will be used as a translated string).
// "translation" — Column contains translated string (when imported file already contains translations).
// "context" — Column contains some comments on source string. Context information.
// "max_length" — Column contains max. length of translation for this string.
// "none" — Do not import column.
Scheme string
// Used when uploading CSV (or XLS/XLSX) files via API. Defines whether first line should be imported or it contains columns headers. May not contain value.
FirstLineContainsHeader bool
// Files array that should be added to Crowdin project. Array keys should contain file names with path in Crowdin project.
Files map[string]string
}
// UploadTranslationsOptions are options for UploadTranslations api call
type UploadTranslationsOptions struct {
// Target language. With a single call it's possible to upload translations for several files but only into one of the languages.
Language string
// Translated files array. Array keys should contain file names in Crowdin.
Files map[string]string
// Defines whether to add translation if there is the same translation previously added. Acceptable values are: 0 or 1. Default is 0.
ImportDuplicates string
}
// ChangeDirectoryOptions are options for ChangeDirectory api call
type ChangeDirectoryOptions struct {
// Full directory path that should be modified (e.g. /MainPage/AboutUs).
Name string
// New directory name.
NewName string
// New directory title to be displayed in Crowdin UI.
Title string
}
// CreateProjectOptions are options for CreateProject api call
type CreateProjectOptions struct {
// Project name.
Name string
// Project identifier. Should be unique among other Crowdin projects.
Identifier string
// Source files language. Should be a two letters language code.
SourceLanguage string
// An array of language codes project should be translate to.
Languages []string
// Project join policy. Acceptable values are: open, private
JoinPolicy string
}
// EditProjectOptions are options for EditProject api call
type EditProjectOptions struct {
// Project name.
Name string
// An array of language codes project should be translate to.
Languages []string
// Project join policy. Acceptable values are: open, private
JoinPolicy string
}
// ExportFileOptions are options for ExportFile api call
type ExportFileOptions struct {
// This parameter specifies a path to the file that should be exported from the project.
CrowdinFile string
// Crowdin language code.
Language string
// Path to the file name that file will be exported to.
LocalPath string
}
// DownloadOptions are options for DownloadTranslations api call
type DownloadOptions struct {
// Language code or "all" to download a bundle with translations to all languages.
Package string
// Path to the file name that file will be exported to.
LocalPath string
}
type responseLanguageStatus struct {
Files []struct {
ID string `json:"id"`
Name string `json:"name"`
NodeType string `json:"node_type"`
Phrases string `json:"phrases"`
Translated string `json:"translated"`
Approved string `json:"approved"`
Words string `json:"words"`
WordsTranslated string `json:"words_translated"`
WordsApproved string `json:"words_approved"`
} `json:"files"`
}
type responseAddFile struct {
Success bool `json:"success"`
Stats struct {
Files []struct {
FileID int `json:"file_id"`
Name string `json:"name"`
Strings int `json:"strings"`
Words int `json:"words"`
} `json:"files"`
} `json:"stats"`
}
type responseUploadTranslation struct {
Success bool `json:"success"`
Stats struct {
Files []struct {
Name string `json:"name"`
Status string `json:"status"`
} `json:"files"`
} `json:"stats"`
}
type responseManageProject struct {
Project struct {
Success bool `json:"success"`
Invitation string `json:"invitation"`
URL string `json:"url"`
Key string `json:"key"`
} `json:"project"`
}
type responseDeleteProject struct {
Project struct {
Success bool `json:"success"`
} `json:"project"`
}
type responseExportTranslations struct {
Success struct {
Status string `json:"status"`
} `json:"success"`
}
// TranslationStatus is a response struct
type TranslationStatus struct {
Name string `json:"name"`
Code string `json:"code"`
Phrases string `json:"phrases"`
Translated string `json:"translated"`
Approved string `json:"approved"`
Words string `json:"words"`
WordsTranslated string `json:"words_translated"`
WordsApproved string `json:"words_approved"`
TranslatedProgress int `json:"translated_progress"`
ApprovedProgress int `json:"approved_progress"`
}
// ExportStatus is a response struct
type ExportStatus struct {
Status string `json:"status"`
Progress int `json:"progress"`
LastBuild string `json:"last_build"`
Code string `json:"code"`
Message string `json:"message"`
CurrentFile string `json:"current_file"`
CurrentLanguage string `json:"current_language"`
}
// ProjectInfo is a response struct
type ProjectInfo struct {
Files []struct {
Name string `json:"name"`
NodeType string `json:"node_type"`
Created string `json:"created"`
LastUpdated string `json:"last_updated"`
LastAccessed string `json:"last_accessed"`
LastRevision string `json:"last_revision"`
} `json:"files"`
Language struct {
Name string `json:"name"`
Code string `json:"code"`
CanTranslate int `json:"can_translate"`
CanApprove int `json:"can_approve"`
}
Details struct {
SourceLanguage struct {
Name string `json:"name"`
Code string `json:"code"`
} `json:"source_language"`
Name string `json:"name"`
Identifier string `json:"identifier"`
Created string `json:"created"`
Description string `json:"description"`
JoinPolicy string `json:"private"`
LastBuild string `json:"last_build"`
LastActivity string `json:"last_activity"`
ParticipantsCount string `json:"participants_count"`
TotalStringsCount string `json:"total_strings_count"`
TotalWordsCount string `json:"total_words_count"`
DuplicateStringsCount int `json:"duplicate_strings_count"`
DuplicateWordsCount int `json:"duplicate_words_count"`
InviteURL struct {
Translator string `json:"translator"`
Proofreader string `json:"proofreader"`
} `json:"invite_url"`
} `json:"details"`
}
// AccountDetails is a response struct
type AccountDetails struct {
Success bool `json:"success"`
Projects []struct {
Role string `json:"role"`
Name string `json:"name"`
Identifier string `json:"identifier"`
Downloadable int `json:"downloadable"`
Key string `json:"key"`
} `json:"projects"`
}
type responseGeneral struct {
Success bool `json:"success"`
}