crowdin-cli 0.3.3 → 0.3.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +357 -346
- data/bin/crowdin-cli +53 -28
- data/lib/crowdin-cli/version.rb +1 -1
- data/locales/en.yml +3 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7bd2f204296c8196c211cd9a575b8bf00595cb82
|
4
|
+
data.tar.gz: e08994a523db83bf8b033f2839c2da8cdc8309ef
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 30e1900a5015424aaba07cd7462fc749b5c826fe8afb80b86115664e183fb76a0051c5ec8173801c780c5210a4d4394f2442239e403a8f930fffda87dbefd6c4
|
7
|
+
data.tar.gz: c2d0becec299aaec690a6947eb35d1c6b97e644515df761e968aa08e5bdb582bc94df12bf503720cf20dc34db0e37c6d4bdc5c63881d081151bdc3f8fcc957e8
|
data/README.md
CHANGED
@@ -1,346 +1,357 @@
|
|
1
|
-
# Crowdin-CLI
|
2
|
-
|
3
|
-
[Crowdin Integration Utility Homepage](http://crowdin.net/page/cli-tool)
|
4
|
-
[Support](http://crowdin.net/contacts)
|
5
|
-
[Crowdin.net Homepage](http://crowdin.net)
|
6
|
-
[crowdin-api RubyDoc](http://rubydoc.info/github/crowdin/crowdin-api/)
|
7
|
-
|
8
|
-
A Command-Line Interface to sync files between local computer/server and [Crowdin](crowdin.net).
|
9
|
-
|
10
|
-
It is cross-platform and can be run in a terminal (Linux, MacOS X) or in cmd.exe (Windows).
|
11
|
-
|
12
|
-
![ScreenShot](https://raw.github.com/crowdin/crowdin-cli/master/screenshot.png)
|
13
|
-
|
14
|
-
> **WARNING**: This is a development version: It contains the latest changes, but may also have several known issues, including crashes and data loss situations. In fact, it may not work at all.
|
15
|
-
|
16
|
-
## Installation
|
17
|
-
|
18
|
-
Add this line to your application's Gemfile:
|
19
|
-
|
20
|
-
```
|
21
|
-
gem 'crowdin-cli'
|
22
|
-
```
|
23
|
-
|
24
|
-
And then execute:
|
25
|
-
```
|
26
|
-
$ bundle
|
27
|
-
```
|
28
|
-
|
29
|
-
Or install it manually as:
|
30
|
-
```
|
31
|
-
$ gem install crowdin-cli
|
32
|
-
```
|
33
|
-
|
34
|
-
## Configuration
|
35
|
-
|
36
|
-
When the tool is installed, you would have to configure your project. Basically, `crowdin-cli` go through project directory, and looks for `crowdin.yaml` file that contains project information.
|
37
|
-
|
38
|
-
Create `crowdin.yaml` YAML file in your root project directory with the following structure:
|
39
|
-
|
40
|
-
```
|
41
|
-
---
|
42
|
-
project_idenfier: test
|
43
|
-
api_key: KeepTheAPIkeySecret
|
44
|
-
base_url: http://api.crowdin.net
|
45
|
-
base_path: /path/to/your/project
|
46
|
-
|
47
|
-
files:
|
48
|
-
-
|
49
|
-
source: /locale/en/LC_MESSAGES/messages.po
|
50
|
-
translation: /locale/%two_letters_code%/LC_MESSAGES/%original_file_name%
|
51
|
-
```
|
52
|
-
|
53
|
-
* `api_key` - Crowdin Project API key
|
54
|
-
* `project_identifier` - Crowdin project name
|
55
|
-
* `base_url` - (default: http://api.crowdin.net)
|
56
|
-
* `base_path` - defines what directory have to be scaned(default: current directory)
|
57
|
-
* `files`
|
58
|
-
* `source` - defines only files that should be uploaded as sources
|
59
|
-
* `translation` - defines where translations should be placed after downloading (also the path have to be checked to detect and upload existing translations)
|
60
|
-
|
61
|
-
Use the following placeholders to put appropriate variables into the resulting file name:
|
62
|
-
* `%language%` - Language name (i.e. Ukrainian)
|
63
|
-
* `%two_letters_code%` - Language code ISO 639-1 (i.e. uk)
|
64
|
-
* `%three_letters_code%` - Language code ISO 639-2/T (i.e. ukr)
|
65
|
-
* `%locale%` - Locale (like uk-UA)
|
66
|
-
* `%locale_with_underscore%` - Locale (i.e. uk_UA)
|
67
|
-
* `%original_file_name%` - Original file name
|
68
|
-
* `%android_code%` - Android Locale identifier used to name "values-" directories
|
69
|
-
* `%original_path%` - Take parent folders names in Crowdin project to build file path in resulted bundle
|
70
|
-
* `%file_extension%` - Original file extension
|
71
|
-
* `%file_name%` - File name without extension
|
72
|
-
|
73
|
-
Example for Android projects:
|
74
|
-
```
|
75
|
-
/values-%android_code%/%original_file_name%
|
76
|
-
```
|
77
|
-
Example for Gettext projects:
|
78
|
-
```
|
79
|
-
/locale/%two_letters_code%/LC_MESSAGES/%original_file_name%
|
80
|
-
```
|
81
|
-
|
82
|
-
Also you can add and upload all directories matching the pattern, including all nested files and localizable files.
|
83
|
-
|
84
|
-
Configuration example provided above has 'source' and 'translation' attributes containing standard wildcards (also known as globbing patterns) to make it easier to work with multiple files.
|
85
|
-
|
86
|
-
Here's patterns you can use:
|
87
|
-
|
88
|
-
* `*` (asterisk)
|
89
|
-
|
90
|
-
Match zero or more characters in file name. A glob consisting of only the asterisk and no other characters will match all files in the directory. If you specified a `*.json` it will include all files like `messages.json`, `about_us.json` and anything that ends with `.json`.c* will match all files beginning with c; `*c` will match all files ending with c; and `*c*` will match all files that have c in them (including at the beginning or end). Equivalent to `/ .* /x` in regexp.
|
91
|
-
|
92
|
-
* `**` (doubled asterisk)
|
93
|
-
|
94
|
-
Match all the directories recursively. Note that you can use `**` in `source` and in `translation` pattern. When using `**` in `translation` pattern it will always contain sub-path from `source` for certain file. The mask `**` can be used only once in the pattern and must be surrounded by backslashes `/`.
|
95
|
-
|
96
|
-
* `?` (question mark)
|
97
|
-
|
98
|
-
Matches any one character.
|
99
|
-
|
100
|
-
* `[set]`
|
101
|
-
|
102
|
-
Matches any one character in set. Behaves exactly like character sets in `Regexp`, including set negation (`[^a-z]`).
|
103
|
-
|
104
|
-
* `\` (backslash)
|
105
|
-
|
106
|
-
Escapes the next metacharacter.
|
107
|
-
|
108
|
-
Say, you can have source: `/en/**/*.po` to upload all `*.po` files to Crowdin recursively. `translation` pattern will be `/translations/%two_letters_code%/**/%original_file_name%'`.
|
109
|
-
|
110
|
-
See sample configuration below::
|
111
|
-
```
|
112
|
-
---
|
113
|
-
project_identifier: test
|
114
|
-
api_key: KeepTheAPIkeySecret
|
115
|
-
base_url: http://api.crowdin.net
|
116
|
-
base_path: /path/to/your/project
|
117
|
-
|
118
|
-
files:
|
119
|
-
-
|
120
|
-
source: /locale/en/**/*.po
|
121
|
-
translation: /locale/%two_letters_code%/**/%original_file_name%
|
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
|
-
project_identifier: test
|
190
|
-
api_key: KeepTheAPIkeySecret
|
191
|
-
base_url: http://api.crowdin.net
|
192
|
-
base_path: /path/to/your/project
|
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
|
-
|
1
|
+
# Crowdin-CLI
|
2
|
+
|
3
|
+
[Crowdin Integration Utility Homepage](http://crowdin.net/page/cli-tool)
|
4
|
+
| [Support](http://crowdin.net/contacts)
|
5
|
+
| [Crowdin.net Homepage](http://crowdin.net)
|
6
|
+
| [crowdin-api RubyDoc](http://rubydoc.info/github/crowdin/crowdin-api/)
|
7
|
+
|
8
|
+
A Command-Line Interface to sync files between local computer/server and [Crowdin](crowdin.net).
|
9
|
+
|
10
|
+
It is cross-platform and can be run in a terminal (Linux, MacOS X) or in cmd.exe (Windows).
|
11
|
+
|
12
|
+
![ScreenShot](https://raw.github.com/crowdin/crowdin-cli/master/screenshot.png)
|
13
|
+
|
14
|
+
> **WARNING**: This is a development version: It contains the latest changes, but may also have several known issues, including crashes and data loss situations. In fact, it may not work at all.
|
15
|
+
|
16
|
+
## Installation
|
17
|
+
|
18
|
+
Add this line to your application's Gemfile:
|
19
|
+
|
20
|
+
```
|
21
|
+
gem 'crowdin-cli'
|
22
|
+
```
|
23
|
+
|
24
|
+
And then execute:
|
25
|
+
```
|
26
|
+
$ bundle
|
27
|
+
```
|
28
|
+
|
29
|
+
Or install it manually as:
|
30
|
+
```
|
31
|
+
$ gem install crowdin-cli
|
32
|
+
```
|
33
|
+
|
34
|
+
## Configuration
|
35
|
+
|
36
|
+
When the tool is installed, you would have to configure your project. Basically, `crowdin-cli` go through project directory, and looks for `crowdin.yaml` file that contains project information.
|
37
|
+
|
38
|
+
Create `crowdin.yaml` YAML file in your root project directory with the following structure:
|
39
|
+
|
40
|
+
```
|
41
|
+
---
|
42
|
+
project_idenfier: test
|
43
|
+
api_key: KeepTheAPIkeySecret
|
44
|
+
base_url: http://api.crowdin.net
|
45
|
+
base_path: /path/to/your/project
|
46
|
+
|
47
|
+
files:
|
48
|
+
-
|
49
|
+
source: /locale/en/LC_MESSAGES/messages.po
|
50
|
+
translation: /locale/%two_letters_code%/LC_MESSAGES/%original_file_name%
|
51
|
+
```
|
52
|
+
|
53
|
+
* `api_key` - Crowdin Project API key
|
54
|
+
* `project_identifier` - Crowdin project name
|
55
|
+
* `base_url` - (default: http://api.crowdin.net)
|
56
|
+
* `base_path` - defines what directory have to be scaned(default: current directory)
|
57
|
+
* `files`
|
58
|
+
* `source` - defines only files that should be uploaded as sources
|
59
|
+
* `translation` - defines where translations should be placed after downloading (also the path have to be checked to detect and upload existing translations)
|
60
|
+
|
61
|
+
Use the following placeholders to put appropriate variables into the resulting file name:
|
62
|
+
* `%language%` - Language name (i.e. Ukrainian)
|
63
|
+
* `%two_letters_code%` - Language code ISO 639-1 (i.e. uk)
|
64
|
+
* `%three_letters_code%` - Language code ISO 639-2/T (i.e. ukr)
|
65
|
+
* `%locale%` - Locale (like uk-UA)
|
66
|
+
* `%locale_with_underscore%` - Locale (i.e. uk_UA)
|
67
|
+
* `%original_file_name%` - Original file name
|
68
|
+
* `%android_code%` - Android Locale identifier used to name "values-" directories
|
69
|
+
* `%original_path%` - Take parent folders names in Crowdin project to build file path in resulted bundle
|
70
|
+
* `%file_extension%` - Original file extension
|
71
|
+
* `%file_name%` - File name without extension
|
72
|
+
|
73
|
+
Example for Android projects:
|
74
|
+
```
|
75
|
+
/values-%android_code%/%original_file_name%
|
76
|
+
```
|
77
|
+
Example for Gettext projects:
|
78
|
+
```
|
79
|
+
/locale/%two_letters_code%/LC_MESSAGES/%original_file_name%
|
80
|
+
```
|
81
|
+
|
82
|
+
Also you can add and upload all directories matching the pattern, including all nested files and localizable files.
|
83
|
+
|
84
|
+
Configuration example provided above has 'source' and 'translation' attributes containing standard wildcards (also known as globbing patterns) to make it easier to work with multiple files.
|
85
|
+
|
86
|
+
Here's patterns you can use:
|
87
|
+
|
88
|
+
* `*` (asterisk)
|
89
|
+
|
90
|
+
Match zero or more characters in file name. A glob consisting of only the asterisk and no other characters will match all files in the directory. If you specified a `*.json` it will include all files like `messages.json`, `about_us.json` and anything that ends with `.json`.c* will match all files beginning with c; `*c` will match all files ending with c; and `*c*` will match all files that have c in them (including at the beginning or end). Equivalent to `/ .* /x` in regexp.
|
91
|
+
|
92
|
+
* `**` (doubled asterisk)
|
93
|
+
|
94
|
+
Match all the directories recursively. Note that you can use `**` in `source` and in `translation` pattern. When using `**` in `translation` pattern it will always contain sub-path from `source` for certain file. The mask `**` can be used only once in the pattern and must be surrounded by backslashes `/`.
|
95
|
+
|
96
|
+
* `?` (question mark)
|
97
|
+
|
98
|
+
Matches any one character.
|
99
|
+
|
100
|
+
* `[set]`
|
101
|
+
|
102
|
+
Matches any one character in set. Behaves exactly like character sets in `Regexp`, including set negation (`[^a-z]`).
|
103
|
+
|
104
|
+
* `\` (backslash)
|
105
|
+
|
106
|
+
Escapes the next metacharacter.
|
107
|
+
|
108
|
+
Say, you can have source: `/en/**/*.po` to upload all `*.po` files to Crowdin recursively. `translation` pattern will be `/translations/%two_letters_code%/**/%original_file_name%'`.
|
109
|
+
|
110
|
+
See sample configuration below::
|
111
|
+
```
|
112
|
+
---
|
113
|
+
project_identifier: test
|
114
|
+
api_key: KeepTheAPIkeySecret
|
115
|
+
base_url: http://api.crowdin.net
|
116
|
+
base_path: /path/to/your/project
|
117
|
+
|
118
|
+
files:
|
119
|
+
-
|
120
|
+
source: /locale/en/**/*.po
|
121
|
+
translation: /locale/%two_letters_code%/**/%original_file_name%
|
122
|
+
```
|
123
|
+
|
124
|
+
### Split project configuration and user credentials
|
125
|
+
|
126
|
+
The `crowdin.yaml` file contains project-specific configuration and user credentials(`api_key`, `project_identifier`).
|
127
|
+
This means that you can't commit this file in the code repository, because the API key would leak to other users. `crowdin-cli` allow 2 configuration files:
|
128
|
+
|
129
|
+
* a project-specific, residing in the project directory (required)
|
130
|
+
* a user-specific, probably residing in `$HOME/.crowdin.yaml` (optional)
|
131
|
+
|
132
|
+
**NOTE**: user credentials in user-specific configuration file is higher priority than project-specific.
|
133
|
+
|
134
|
+
### Languages mapping
|
135
|
+
|
136
|
+
Often software projects have custom names for locale directories. `crowdin-cli` allows you to map your own languages to understandable by Crowdin.
|
137
|
+
|
138
|
+
Let's say your locale directories named 'en', 'uk', 'fr', 'de'. All of them can be represented by `%two_letters_code%` placeholder. Still, you have one directory named 'zh_CH'. In order to make it work with `crowdin-cli` without changes in your project you can add `languages_mapping` section to your files set. See sample configuration below:
|
139
|
+
|
140
|
+
```
|
141
|
+
---
|
142
|
+
project_identifier: test
|
143
|
+
api_key: KeepTheAPIkeySecret
|
144
|
+
base_url: http://api.crowdin.net
|
145
|
+
base_path: /path/to/your/project
|
146
|
+
|
147
|
+
files:
|
148
|
+
-
|
149
|
+
source: /locale/en/**/*.po
|
150
|
+
translation: /locale/%two_letters_code%/**/%original_file_name%
|
151
|
+
languages_mapping:
|
152
|
+
two_letters_code:
|
153
|
+
# crowdin_language_code: local_name
|
154
|
+
ru: ros
|
155
|
+
uk: ukr
|
156
|
+
```
|
157
|
+
Mapping format is the following: `crowdin_language_code : code_use_use`.
|
158
|
+
|
159
|
+
Check [complete list of Crowdin language codes](http://crowdin.net/page/api/language-codes) that can be used for mapping.
|
160
|
+
|
161
|
+
You can also override language codes for other placeholders like `%android_code%`, `%locale%` etc...
|
162
|
+
|
163
|
+
### Ignoring directories
|
164
|
+
|
165
|
+
From time to time there are files and directories you don't want translate on Crowdin.
|
166
|
+
Local per-file rules can be added to the config file in your project.
|
167
|
+
|
168
|
+
```
|
169
|
+
files:
|
170
|
+
-
|
171
|
+
source: /locale/en/**/*.po
|
172
|
+
translation: /locale/%two_letters_code%/**/%original_file_name%
|
173
|
+
ignore:
|
174
|
+
- /locale/en/templates
|
175
|
+
- /locale/en/**/test-*.po
|
176
|
+
- /locale/en/**/[^abc]*.po
|
177
|
+
|
178
|
+
```
|
179
|
+
|
180
|
+
### Preserving directories hierarchy
|
181
|
+
|
182
|
+
By default CLI tool tries to optimize your Crowdin project hierarchy and do not repeats complete path of local files online.
|
183
|
+
In case you need to keep directories structure same at Crowdin and locally you can add `preserve_hierarchy: true` option in main section of the configuration file.
|
184
|
+
|
185
|
+
Configuration sample is below:
|
186
|
+
|
187
|
+
```
|
188
|
+
---
|
189
|
+
project_identifier: test
|
190
|
+
api_key: KeepTheAPIkeySecret
|
191
|
+
base_url: http://api.crowdin.net
|
192
|
+
base_path: /path/to/your/project
|
193
|
+
preserve_hierarchy: true
|
194
|
+
```
|
195
|
+
|
196
|
+
### Uploading CSV files via API
|
197
|
+
|
198
|
+
```
|
199
|
+
---
|
200
|
+
project_identifier: test
|
201
|
+
api_key: KeepTheAPIkeySecret
|
202
|
+
base_url: http://api.crowdin.net
|
203
|
+
base_path: /path/to/your/project
|
204
|
+
|
205
|
+
files:
|
206
|
+
-
|
207
|
+
source: '/*.csv'
|
208
|
+
translation: '%two_letters_code%/%original_file_name%'
|
209
|
+
# Defines whether first line should be imported or it contains columns headers
|
210
|
+
first_line_contains_header: true
|
211
|
+
# Used only when uploading CSV file to define data columns mapping.
|
212
|
+
scheme: "identifier,source_phrase,translation,context,max_length"
|
213
|
+
```
|
214
|
+
|
215
|
+
#### Multicolumn CSV
|
216
|
+
|
217
|
+
In case CSV file contains translations to all target languages you can use per-file option `multilingual_spreadsheet`.
|
218
|
+
|
219
|
+
CSV file example:
|
220
|
+
```
|
221
|
+
identifier,source_phrase,context,Ukrainian,Russian,French
|
222
|
+
ident1,Source 1,Context 1,,,
|
223
|
+
ident2,Source 2,Context 2,,,
|
224
|
+
ident3,Source 3,Context 3,,,
|
225
|
+
```
|
226
|
+
|
227
|
+
Configuration file example:
|
228
|
+
```
|
229
|
+
files:
|
230
|
+
-
|
231
|
+
source: multicolumn.csv
|
232
|
+
translation: multicolumn.csv
|
233
|
+
first_line_contains_header: true
|
234
|
+
scheme: "identifier,source_phrase,context,uk,ru,fr"
|
235
|
+
multilingual_spreadsheet: true
|
236
|
+
|
237
|
+
```
|
238
|
+
|
239
|
+
|
240
|
+
## Configurations Examples
|
241
|
+
|
242
|
+
### GetText Project
|
243
|
+
|
244
|
+
```
|
245
|
+
---
|
246
|
+
project_identifier: test
|
247
|
+
api_key: KeepTheAPIkeySecret
|
248
|
+
base_url: http://api.crowdin.net
|
249
|
+
base_path: /path/to/your/project
|
250
|
+
|
251
|
+
files:
|
252
|
+
-
|
253
|
+
source: '/locale/en/**/*.po'
|
254
|
+
translation: '/locale/%two_letters_code%/LC_MESSAGES/%original_file_name%'
|
255
|
+
languages_mapping:
|
256
|
+
two_letters_code:
|
257
|
+
'zh-CN': 'zh_CH'
|
258
|
+
'fr-QC': 'fr'
|
259
|
+
```
|
260
|
+
|
261
|
+
### Android Project
|
262
|
+
|
263
|
+
```
|
264
|
+
---
|
265
|
+
project_identifier: test
|
266
|
+
api_key: KeepTheAPIkeySecret
|
267
|
+
base_url: http://api.crowdin.net
|
268
|
+
base_path: /path/to/your/project
|
269
|
+
|
270
|
+
files:
|
271
|
+
-
|
272
|
+
source: '/res/values/*.xml'
|
273
|
+
translation: '/res/values-%android_code%/%original_file_name%'
|
274
|
+
languages_mapping:
|
275
|
+
android_code:
|
276
|
+
# we need this mapping since Crowdin expects directories
|
277
|
+
# to be named like "values-uk-rUA"
|
278
|
+
# acording to specification instead of just "uk"
|
279
|
+
de: de
|
280
|
+
ru: ru
|
281
|
+
```
|
282
|
+
|
283
|
+
## Usage
|
284
|
+
|
285
|
+
When the configuration file is created, you are ready to start using `crowdin-cli` to manage your localization resources and automate files synchronization.
|
286
|
+
|
287
|
+
We listed most typical commands that crowdin-cli is used for:
|
288
|
+
|
289
|
+
Upload your source files to Crowdin:
|
290
|
+
```
|
291
|
+
$ crowdin-cli upload sources
|
292
|
+
```
|
293
|
+
|
294
|
+
Upload existing translations to Crowdin project (translations will be synchronized):
|
295
|
+
```
|
296
|
+
$ crowdin-cli upload translations
|
297
|
+
```
|
298
|
+
|
299
|
+
Download latest translations from Crowdin:
|
300
|
+
```
|
301
|
+
$ crowdin-cli download
|
302
|
+
```
|
303
|
+
|
304
|
+
List information about the files that already exists in current project:
|
305
|
+
```
|
306
|
+
$ crowdin-cli list project
|
307
|
+
```
|
308
|
+
|
309
|
+
List information about the sources files in current project that match the wild-card pattern:
|
310
|
+
```
|
311
|
+
$ crowdin-cli list sources
|
312
|
+
```
|
313
|
+
|
314
|
+
List information about the translations files in current project that match the wild-card pattern:
|
315
|
+
```
|
316
|
+
$ crowdin-cli list translations
|
317
|
+
```
|
318
|
+
|
319
|
+
By default, `list` command print a list of all the files
|
320
|
+
Also, `list` accept `-tree` optional argument to list contents in a tree-like format.
|
321
|
+
|
322
|
+
|
323
|
+
Get help on `upload` command:
|
324
|
+
```
|
325
|
+
$ crowdin-cli help upload
|
326
|
+
```
|
327
|
+
|
328
|
+
Get help on `upload sources` command:
|
329
|
+
```
|
330
|
+
$ crowdin-cli help upload sources
|
331
|
+
```
|
332
|
+
|
333
|
+
Use help provided with an application to get more information about available commands and options:
|
334
|
+
|
335
|
+
|
336
|
+
## Supported Rubies
|
337
|
+
|
338
|
+
Tested with the following Ruby versions:
|
339
|
+
|
340
|
+
- MRI 1.9.3
|
341
|
+
- JRuby 1.7.0
|
342
|
+
|
343
|
+
## Contributing
|
344
|
+
|
345
|
+
1. Fork it
|
346
|
+
2. Create your feature branch (`git checkout -b my-new-feature`)
|
347
|
+
3. Commit your changes (`git commit -am 'Added some feature'`)
|
348
|
+
4. Push to the branch (`git push origin my-new-feature`)
|
349
|
+
5. Create new Pull Request
|
350
|
+
|
351
|
+
## License and Author
|
352
|
+
|
353
|
+
Author: Anton Maminov (anton.maminov@gmail.com)
|
354
|
+
|
355
|
+
Copyright: 2012-2014 [Crowdin.net](http://crowdin.net/)
|
356
|
+
|
357
|
+
This project is licensed under the MIT license, a copy of which can be found in the LICENSE file.
|
data/bin/crowdin-cli
CHANGED
@@ -325,6 +325,12 @@ default_value File.join(Dir.pwd, 'crowdin.yaml')
|
|
325
325
|
arg_name '<s>'
|
326
326
|
flag [:c, :config]
|
327
327
|
|
328
|
+
desc I18n.t('app.flags.identity.desc')
|
329
|
+
default_value File.join(Dir.home, '.crowdin.yaml')
|
330
|
+
arg_name '<s>'
|
331
|
+
flag [:identity]
|
332
|
+
|
333
|
+
|
328
334
|
desc I18n.t('app.commands.upload.desc')
|
329
335
|
long_desc I18n.t('app.commands.upload.long_desc')
|
330
336
|
command :upload do |c|
|
@@ -364,9 +370,9 @@ command :upload do |c|
|
|
364
370
|
|
365
371
|
local_file = { dest: dest, source: File.join(@base_path, file['source']), export_pattern: file['translation'] }
|
366
372
|
|
367
|
-
|
368
|
-
|
369
|
-
|
373
|
+
@allowed_options.each do |option|
|
374
|
+
local_file.merge!({ option.to_sym => file[option] }) if file.has_key?(option)
|
375
|
+
end
|
370
376
|
|
371
377
|
local_files << local_file
|
372
378
|
else
|
@@ -388,9 +394,9 @@ command :upload do |c|
|
|
388
394
|
|
389
395
|
local_file = { dest: dest, source: source_path, export_pattern: export_pattern }
|
390
396
|
|
391
|
-
|
392
|
-
|
393
|
-
|
397
|
+
@allowed_options.each do |option|
|
398
|
+
local_file.merge!({ option.to_sym => file[option] }) if file.has_key?(option)
|
399
|
+
end
|
394
400
|
|
395
401
|
local_files << local_file
|
396
402
|
end
|
@@ -431,9 +437,9 @@ EOS
|
|
431
437
|
print "Updating source file `#{file[:dest]}'"
|
432
438
|
|
433
439
|
params = {}
|
434
|
-
|
435
|
-
|
436
|
-
|
440
|
+
@allowed_options.each do |option|
|
441
|
+
params[option.to_sym] = file.delete(option.to_sym)
|
442
|
+
end
|
437
443
|
|
438
444
|
resp = @crowdin.update_file([] << file, params)
|
439
445
|
|
@@ -454,8 +460,9 @@ EOS
|
|
454
460
|
print "Uploading source file `#{file[:dest]}'"
|
455
461
|
|
456
462
|
params = {}
|
457
|
-
|
458
|
-
|
463
|
+
@allowed_options.each do |option|
|
464
|
+
params[option.to_sym] = file.delete(option.to_sym)
|
465
|
+
end
|
459
466
|
|
460
467
|
resp = @crowdin.add_file([] << file, params)
|
461
468
|
|
@@ -767,9 +774,9 @@ command :list do |ls_cmd|
|
|
767
774
|
|
768
775
|
local_file = { dest: dest, source: File.join(@base_path, file['source']), export_pattern: file['translation'] }
|
769
776
|
|
770
|
-
|
771
|
-
|
772
|
-
|
777
|
+
@allowed_options.each do |option|
|
778
|
+
local_file.merge!({ option.to_sym => file[option] }) if file.has_key?(option)
|
779
|
+
end
|
773
780
|
|
774
781
|
local_files << local_file
|
775
782
|
else
|
@@ -791,9 +798,9 @@ command :list do |ls_cmd|
|
|
791
798
|
|
792
799
|
local_file = { dest: dest, source: source_path, export_pattern: export_pattern }
|
793
800
|
|
794
|
-
|
795
|
-
|
796
|
-
|
801
|
+
@allowed_options.each do |option|
|
802
|
+
local_file.merge!({ option.to_sym => file[option] }) if file.has_key?(option)
|
803
|
+
end
|
797
804
|
|
798
805
|
local_files << local_file
|
799
806
|
end
|
@@ -839,7 +846,7 @@ command :list do |ls_cmd|
|
|
839
846
|
|
840
847
|
translation_languages.each do |lang|
|
841
848
|
local_file = export_pattern_to_path(dest, file['translation'], lang, languages_mapping)
|
842
|
-
|
849
|
+
translation_files << local_file
|
843
850
|
end
|
844
851
|
|
845
852
|
else
|
@@ -887,8 +894,34 @@ pre do |globals ,command, options, args|
|
|
887
894
|
# Use skips_pre before a command to skip this block
|
888
895
|
# on that command only
|
889
896
|
|
890
|
-
|
891
|
-
|
897
|
+
@allowed_options = [
|
898
|
+
# CSV files only
|
899
|
+
'scheme',
|
900
|
+
'first_line_contains_header',
|
901
|
+
'update_option',
|
902
|
+
# XML files only
|
903
|
+
'translate_content',
|
904
|
+
'translate_attributes',
|
905
|
+
'content_segmentations',
|
906
|
+
'translate_elements',
|
907
|
+
]
|
908
|
+
|
909
|
+
unless File.exists?(globals[:config])
|
910
|
+
exit_now! <<EOS
|
911
|
+
Can't find configuration file (default `crowdin.yaml').
|
912
|
+
Type `crowdin-cli help` to know how to specify custom configuration file
|
913
|
+
|
914
|
+
See http://crowdin.net/page/cli-tool#configuration-file for more details
|
915
|
+
EOS
|
916
|
+
else
|
917
|
+
@config = YAML.load_file(globals[:config]) || {}
|
918
|
+
|
919
|
+
if File.exists?(globals[:identity])
|
920
|
+
identity = YAML.load_file(globals[:identity]) || {}
|
921
|
+
['api_key', 'project_identifier'].each do |key|
|
922
|
+
@config[key] = identity[key] if identity[key]
|
923
|
+
end
|
924
|
+
end
|
892
925
|
|
893
926
|
['api_key', 'project_identifier'].each do |key|
|
894
927
|
unless @config[key]
|
@@ -907,14 +940,6 @@ Configuration file misses required section `files`
|
|
907
940
|
See http://crowdin.net/page/cli-tool#configuration-file for more details
|
908
941
|
EOS
|
909
942
|
end
|
910
|
-
|
911
|
-
else
|
912
|
-
exit_now! <<EOS
|
913
|
-
Can't find configuration file (default `crowdin.yaml').
|
914
|
-
Type `crowdin-cli help` to know how to specify custom configuration file
|
915
|
-
|
916
|
-
See http://crowdin.net/page/cli-tool#configuration-file for more details
|
917
|
-
EOS
|
918
943
|
end
|
919
944
|
|
920
945
|
@config['files'].each do |file|
|
data/lib/crowdin-cli/version.rb
CHANGED
data/locales/en.yml
CHANGED
@@ -6,7 +6,9 @@ en:
|
|
6
6
|
See http://crowdin.net/page/cli-tool#configuration-file for more details.
|
7
7
|
flags:
|
8
8
|
config:
|
9
|
-
desc:
|
9
|
+
desc: Project-specific configuration file
|
10
|
+
identity:
|
11
|
+
desc: User-specific configuration file with API credentials
|
10
12
|
switches:
|
11
13
|
verbose:
|
12
14
|
desc: Be verbose
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crowdin-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crowdin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-
|
11
|
+
date: 2014-05-31 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|