crowdin-cli 0.0.17 → 0.0.18
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +80 -4
- data/bin/crowdin-cli +18 -9
- data/lib/crowdin-cli/version.rb +1 -1
- metadata +2 -2
data/README.md
CHANGED
@@ -1,9 +1,16 @@
|
|
1
1
|
# Crowdin-CLI
|
2
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
|
+
|
3
8
|
A Command-Line Interface to sync files between your computer/server and [Crowdin](crowdin.net).
|
4
9
|
|
5
10
|
It is cross-platform and runs in a terminal (Linux, MacOS X) or in cmd.exe (Windows).
|
6
11
|
|
12
|
+
![ScreenShot](https://raw.github.com/crowdin/crowdin-cli/master/screenshot.png)
|
13
|
+
|
7
14
|
> **WARNING**: This is a development version: It contains the latest changes, but may also have severe known issues, including crashes and data loss situations. In fact, it may not work at all.
|
8
15
|
|
9
16
|
## Installation
|
@@ -74,7 +81,21 @@ files:
|
|
74
81
|
|
75
82
|
Also you can add and upload all directories mathing the pattern including all nested files and localizable files.
|
76
83
|
|
77
|
-
|
84
|
+
Example configuration 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
|
+
This wildcard represents any character in file or directory name. If you specified a `*.json` it will include all files like `messages.json`, `about_us.json` and anything that ends with `.json`.
|
91
|
+
|
92
|
+
* `**` (doubled asterisk)
|
93
|
+
|
94
|
+
Matches any string recursively (including sub-directories). 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.
|
95
|
+
|
96
|
+
Say, you can have source: `/en/**/*.po` to upload all `*.po` files to Crowdin recursively. `translation` pattern will be `/%two_letters_code%/**/%original_file_name%'`.
|
97
|
+
|
98
|
+
See sample configuration below::
|
78
99
|
```
|
79
100
|
---
|
80
101
|
project_identifier: test
|
@@ -88,7 +109,11 @@ files:
|
|
88
109
|
translation: /locale/%two_letters_code%/**/%original_file_name%
|
89
110
|
```
|
90
111
|
|
91
|
-
Languages mapping
|
112
|
+
### Languages mapping
|
113
|
+
|
114
|
+
Often software projects have custom names for locale directories. `crowdin-cli` allows you to map your own languages to understandable by Crowdin.
|
115
|
+
|
116
|
+
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:
|
92
117
|
|
93
118
|
```
|
94
119
|
---
|
@@ -107,7 +132,54 @@ files:
|
|
107
132
|
ru: ros
|
108
133
|
uk: ukr
|
109
134
|
```
|
110
|
-
|
135
|
+
Mapping format is the following: `crowdin_language_code : code_use_use`.
|
136
|
+
|
137
|
+
Check [complete list of Crowdin language codes](http://crowdin.net/page/api/language-codes) that can be used for mapping.
|
138
|
+
|
139
|
+
You can also override language codes for other placeholders like `%android_code%`, `%locale%` etc...
|
140
|
+
|
141
|
+
## Example Configurations
|
142
|
+
|
143
|
+
### GetText Project
|
144
|
+
|
145
|
+
```
|
146
|
+
---
|
147
|
+
project_identifier: test
|
148
|
+
api_key: KeepTheAPIkeySecret
|
149
|
+
base_url: http://api.crowdin.net
|
150
|
+
base_path: /path/to/your/project
|
151
|
+
|
152
|
+
files:
|
153
|
+
-
|
154
|
+
source: '/locale/en/**/*.po'
|
155
|
+
translation: '/locale/%two_letters_code%/LC_MESSAGES/%original_file_name%'
|
156
|
+
languages_mapping:
|
157
|
+
two_letters_code:
|
158
|
+
'zh-CN': 'zh_CH'
|
159
|
+
'fr-QC': 'fr'
|
160
|
+
```
|
161
|
+
|
162
|
+
### Android Project
|
163
|
+
|
164
|
+
```
|
165
|
+
---
|
166
|
+
project_identifier: test
|
167
|
+
api_key: KeepTheAPIkeySecret
|
168
|
+
base_url: http://api.crowdin.net
|
169
|
+
base_path: /path/to/your/project
|
170
|
+
|
171
|
+
files:
|
172
|
+
-
|
173
|
+
source: '/res/values/*.xml'
|
174
|
+
translation: '/res/values-%android_code%/%original_file_name%'
|
175
|
+
languages_mapping:
|
176
|
+
android_code:
|
177
|
+
# we need this mapping since Crowdin expects directories
|
178
|
+
# to be named like "values-uk-rUA"
|
179
|
+
# acording to specification instead of just "uk"
|
180
|
+
de: de
|
181
|
+
ru: ru
|
182
|
+
```
|
111
183
|
|
112
184
|
## Usage
|
113
185
|
|
@@ -158,6 +230,10 @@ Tested with the following Ruby versions:
|
|
158
230
|
4. Push to the branch (`git push origin my-new-feature`)
|
159
231
|
5. Create new Pull Request
|
160
232
|
|
161
|
-
## License
|
233
|
+
## License and Author
|
234
|
+
|
235
|
+
Author: Anton Maminov (anton.maminov@gmail.com)
|
236
|
+
|
237
|
+
Copyright: 2012 [Crowdin.net](http://crowdin.net/)
|
162
238
|
|
163
239
|
This library is distributed under the MIT license. Please see the LICENSE file.
|
data/bin/crowdin-cli
CHANGED
@@ -99,7 +99,7 @@ def get_invalid_placeholders(export_pattern)
|
|
99
99
|
'%original_file_name%',
|
100
100
|
'%original_path%',
|
101
101
|
'%file_extension%',
|
102
|
-
'%file_name%'
|
102
|
+
'%file_name%',
|
103
103
|
]
|
104
104
|
|
105
105
|
all_placeholders = export_pattern.scan(/%[a-z0-9_]*?%/)
|
@@ -216,10 +216,10 @@ EOS
|
|
216
216
|
local_files << { dest: dest, source: source, export_pattern: export_pattern }
|
217
217
|
end
|
218
218
|
|
219
|
-
end
|
220
|
-
end
|
219
|
+
end # if
|
220
|
+
end # @config['files']
|
221
221
|
|
222
|
-
if
|
222
|
+
if dest_files.empty?
|
223
223
|
exit_now!("Warning: nothing to upload. See http://crowdin.net/page/cli-client#configuration-file for more details.")
|
224
224
|
end
|
225
225
|
|
@@ -294,6 +294,11 @@ EOS
|
|
294
294
|
|
295
295
|
|
296
296
|
c.action do |global_options, options, args|
|
297
|
+
params = {}
|
298
|
+
params[:import_duplicates] = options['import-dublicates'] ? 1 : 0
|
299
|
+
params[:import_eq_suggestions] = options['import-eq-suggestions'] ? 1 : 0
|
300
|
+
params[:auto_approve_imported] = options['auto-approve-imported'] ? 1 : 0
|
301
|
+
|
297
302
|
language = options[:language]
|
298
303
|
|
299
304
|
project_info = @crowdin.project_info
|
@@ -353,16 +358,12 @@ EOS
|
|
353
358
|
exit_now!("Warning: nothing to upload. See http://crowdin.net/page/cli-client#configuration-file for more details.")
|
354
359
|
end
|
355
360
|
|
356
|
-
params = {}
|
357
|
-
params[:import_duplicates] = options['import-dublicates'] ? 1 : 0
|
358
|
-
params[:import_eq_suggestions] = options['import-eq-suggestions'] ? 1 : 0
|
359
|
-
params[:auto_approve_imported] = options['auto-approve-imported'] ? 1 : 0
|
360
|
-
|
361
361
|
common_dir = find_common_directory_path(dest_files)
|
362
362
|
|
363
363
|
translated_files.each do |language, files|
|
364
364
|
files.each do |file|
|
365
365
|
file[:dest].sub!(common_dir, '')
|
366
|
+
|
366
367
|
if remote_project_tree[:files].include?(file[:dest])
|
367
368
|
if File.exist?(file[:source])
|
368
369
|
print "Uploading `#{file[:source].sub(@base_path, '')}'"
|
@@ -375,6 +376,7 @@ EOS
|
|
375
376
|
# if source file not exist, don't upload translation
|
376
377
|
puts "Warning: Skip `#{file[:source].sub(@base_path, '')}'"
|
377
378
|
end
|
379
|
+
|
378
380
|
end
|
379
381
|
end
|
380
382
|
|
@@ -513,12 +515,19 @@ EOS
|
|
513
515
|
end
|
514
516
|
else
|
515
517
|
@base_path = Dir.pwd
|
518
|
+
puts <<EOS
|
519
|
+
Warning: Configuration file misses optional section `base_path`.
|
520
|
+
Set the working directory - `#{@base_path}`
|
521
|
+
|
522
|
+
EOS
|
516
523
|
end
|
517
524
|
|
518
525
|
Crowdin::API.log = Logger.new($stderr) if global[:v]
|
519
526
|
@crowdin = Crowdin::API.new(api_key: @config['api_key'], project_id: @config['project_identifier'], base_url: @config['base_url'] || 'http://api.crowdin.net')
|
520
527
|
begin
|
521
528
|
@crowdin.project_info
|
529
|
+
rescue Crowdin::API::Errors::Error => err
|
530
|
+
raise err
|
522
531
|
rescue
|
523
532
|
exit_now!("Seems Crowdin server API URL is not valid. Please check the `base_url` parameter in the configuration file.")
|
524
533
|
end
|
data/lib/crowdin-cli/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: crowdin-cli
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.18
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-11-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rake
|