1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Crowdin API implementation in PHP. |
4
|
|
|
* |
5
|
|
|
* @copyright Copyright (C) 2016 Nikolai Plath (elkuku) |
6
|
|
|
* @license GNU General Public License version 2 or later |
7
|
|
|
*/ |
8
|
|
|
|
9
|
|
|
namespace ElKuKu\Crowdin; |
10
|
|
|
|
11
|
|
|
/** |
12
|
|
|
* Project class. |
13
|
|
|
* |
14
|
|
|
* @since 1.0.7 |
15
|
|
|
*/ |
16
|
|
|
class Languageproject |
17
|
|
|
{ |
18
|
|
|
/** |
19
|
|
|
* Project name. |
20
|
|
|
* @var string |
21
|
|
|
*/ |
22
|
|
|
public $name; |
23
|
|
|
|
24
|
|
|
/** |
25
|
|
|
* Project identifier. Should be unique among other Crowdin projects. |
26
|
|
|
* @var string |
27
|
|
|
*/ |
28
|
|
|
public $identifier; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* Source files language. Should be a two letters language code. |
32
|
|
|
* @var string |
33
|
|
|
*/ |
34
|
|
|
public $source_language; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* An array of language codes project should be translate to. |
38
|
|
|
* @var array |
39
|
|
|
*/ |
40
|
|
|
public $languages = []; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* Project join policy. Acceptable values are: open, private |
44
|
|
|
* @var string |
45
|
|
|
*/ |
46
|
|
|
public $join_policy; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Defines how project members can access target languages. Acceptable values are: |
50
|
|
|
* - "open" - any translator can access any language. (default) |
51
|
|
|
* - "moderate" - translator should be granted with access to certain language. |
52
|
|
|
* @var string |
53
|
|
|
*/ |
54
|
|
|
public $language_access_policy; |
55
|
|
|
|
56
|
|
|
/** |
57
|
|
|
* Defines whether duplicated strings should be displayed to translators or should be hidden and translated automatically. |
58
|
|
|
* Acceptable values are: 1 or 0. |
59
|
|
|
* @var boolean |
60
|
|
|
*/ |
61
|
|
|
public $hide_duplicates; |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* Defines whether only translated strings will be exported to the final file. We do not recommend to set this |
65
|
|
|
* option if you have text (*.html, *.txt, *.docx etc.) documents in your project since it may damage resulted files. |
66
|
|
|
* Acceptable values are: 1 or 0. |
67
|
|
|
* @var boolean |
68
|
|
|
*/ |
69
|
|
|
public $export_translated_only; |
70
|
|
|
|
71
|
|
|
/** |
72
|
|
|
* If set to 1 only approved translations will be exported in resulted ZIP file. |
73
|
|
|
* Acceptable values are: 1 or 0. |
74
|
|
|
* @var boolean |
75
|
|
|
*/ |
76
|
|
|
public $export_approved_only; |
77
|
|
|
|
78
|
|
|
/** |
79
|
|
|
* Untranslated strings of dialect will be translated automatically in exported file, leveraging translations from main language. |
80
|
|
|
* Acceptable values are: 1 or 0. |
81
|
|
|
* @var boolean |
82
|
|
|
*/ |
83
|
|
|
public $auto_translate_dialects; |
84
|
|
|
|
85
|
|
|
/** |
86
|
|
|
* Defines whether "Download" button visible to everyone on Crowdin webpages. |
87
|
|
|
* Acceptable values are: 1 or 0. |
88
|
|
|
* @var boolean |
89
|
|
|
*/ |
90
|
|
|
public $public_downloads; |
91
|
|
|
|
92
|
|
|
/** |
93
|
|
|
* Defines if translations would be leveraged from Crowdin Global Translation Memory. |
94
|
|
|
* When using this option any translations made in your project will be commited to Crowdin Global TM automatically. |
95
|
|
|
* Acceptable values are: 1 or 0. |
96
|
|
|
* @var boolean |
97
|
|
|
*/ |
98
|
|
|
public $use_global_tm; |
99
|
|
|
|
100
|
|
|
/** |
101
|
|
|
* Project logo at Crowdin. |
102
|
|
|
* @var string |
103
|
|
|
*/ |
104
|
|
|
public $logo; |
105
|
|
|
|
106
|
|
|
/** |
107
|
|
|
* Custom domain name for Crowdin project. |
108
|
|
|
* @var string |
109
|
|
|
*/ |
110
|
|
|
public $cname; |
111
|
|
|
|
112
|
|
|
/** |
113
|
|
|
* Project description. |
114
|
|
|
* @var string |
115
|
|
|
*/ |
116
|
|
|
public $description; |
117
|
|
|
|
118
|
|
|
/** |
119
|
|
|
* Defines whether the In-Context should be active in the project. |
120
|
|
|
* Acceptable values are: 1 or 0. |
121
|
|
|
* @var boolean |
122
|
|
|
*/ |
123
|
|
|
public $in_context; |
124
|
|
|
|
125
|
|
|
/** |
126
|
|
|
* Specify the language code for the In-Context's pseudo-language that will store some operational data. |
127
|
|
|
* @var string |
128
|
|
|
*/ |
129
|
|
|
public $pseudo_language; |
130
|
|
|
|
131
|
|
|
/** |
132
|
|
|
* Open this URL when one of the project files is translated. |
133
|
|
|
* URL will be opened with "project" - project identifier, "language" - language code, "file_id" - Crowdin file identifier and "file" - file name. |
134
|
|
|
* @var string |
135
|
|
|
*/ |
136
|
|
|
public $webhook_file_translated; |
137
|
|
|
|
138
|
|
|
/** |
139
|
|
|
* Open this URL when one of the project files is proofread. |
140
|
|
|
* URL will be opened with "project" - project identifier, "language" - language code, "file_id" - Crowdin file identifier and "file" - file name. |
141
|
|
|
* @var string |
142
|
|
|
*/ |
143
|
|
|
public $webhook_file_proofread; |
144
|
|
|
|
145
|
|
|
/** |
146
|
|
|
* Open this URL when project translation is complete. URL will be opened with "project" - project identifier and "language" - language code. |
147
|
|
|
* @var string |
148
|
|
|
*/ |
149
|
|
|
public $webhook_project_translated; |
150
|
|
|
|
151
|
|
|
/** |
152
|
|
|
* Open this URL when project proofreading is complete. URL will be opened with "project" - project identifier and "language" - language code. |
153
|
|
|
* @var string |
154
|
|
|
*/ |
155
|
|
|
public $webhook_project_proofread; |
156
|
|
|
|
157
|
|
|
/** |
158
|
|
|
* Convert tye object to query string. |
159
|
|
|
* |
160
|
|
|
* @return array |
161
|
|
|
*/ |
162
|
1 |
|
public function toQuery() |
163
|
|
|
{ |
164
|
1 |
|
$array = []; |
165
|
|
|
|
166
|
1 |
|
foreach (get_object_vars($this) as $name => $value) |
167
|
|
|
{ |
168
|
1 |
|
if (null === $value) |
169
|
|
|
{ |
170
|
1 |
|
continue; |
171
|
|
|
} |
172
|
|
|
|
173
|
1 |
|
if (is_array($value)) |
174
|
|
|
{ |
175
|
1 |
|
if (count($value)) |
176
|
|
|
{ |
177
|
1 |
|
foreach ($value as $v) |
178
|
|
|
{ |
179
|
1 |
|
$array[] = [ |
180
|
1 |
|
'name' => $name . '[]', |
181
|
1 |
|
'contents' => $v |
182
|
|
|
]; |
183
|
|
|
} |
184
|
|
|
} |
185
|
|
|
} |
186
|
|
|
else |
187
|
|
|
{ |
188
|
1 |
|
$array[] = [ |
189
|
1 |
|
'name' => $name, |
190
|
1 |
|
'contents' => $value |
191
|
|
|
]; |
192
|
|
|
} |
193
|
|
|
} |
194
|
|
|
|
195
|
1 |
|
return $array; |
196
|
|
|
} |
197
|
|
|
} |
198
|
|
|
|