crowdin-cli 0.1.3 → 0.1.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 +3 -3
- data/bin/crowdin-cli +66 -21
- data/lib/crowdin-cli/version.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0a2b8da800c4eb8b7ac83fae71c4f5a367e2957f
|
4
|
+
data.tar.gz: f20547149f0303af7281561df18d4553ee588999
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 65f49b368609972c0f7fd26f92b96fa194ea105eb681fb766f2232f40e178a9e2b190ddbbfa40c121881d58e13c76a6ca52b682665f2396b803a6aafcd50273f
|
7
|
+
data.tar.gz: e2ddd67bca8e0786add4e9f23f98bf81299b8dab6cb8bf3cea7e04300c647ff0cb8fcb5bb1cc7c8a4ac0cc849c05fdcc3d11415499696404c16738377df55351
|
data/README.md
CHANGED
@@ -87,13 +87,13 @@ Here's patterns you can use:
|
|
87
87
|
|
88
88
|
* `*` (asterisk)
|
89
89
|
|
90
|
-
|
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`.
|
91
91
|
|
92
92
|
* `**` (doubled asterisk)
|
93
93
|
|
94
|
-
|
94
|
+
Match all 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
95
|
|
96
|
-
Say, you can have source: `/en/**/*.po` to upload all `*.po` files to Crowdin recursively. `translation` pattern will be
|
96
|
+
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%'`.
|
97
97
|
|
98
98
|
See sample configuration below::
|
99
99
|
```
|
data/bin/crowdin-cli
CHANGED
@@ -1,5 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
+
require 'pp'
|
3
4
|
require 'crowdin-cli'
|
4
5
|
|
5
6
|
# GLI_DEBUG=true bundle exec bin/crowdin-cli
|
@@ -80,6 +81,49 @@ def export_pattern_to_path(path, export_pattern, lang, languages_mapping = nil)
|
|
80
81
|
export_pattern.gsub(/%(#{placeholders.join('|')})%/, pattern)
|
81
82
|
end
|
82
83
|
|
84
|
+
# @param [String] path relative path to file in Crowdin project
|
85
|
+
# @param [String] source basically, is a file['source'] from crowdin.yaml
|
86
|
+
# @param [String] translation basically, is a file['translation'] from crowdin.yaml
|
87
|
+
#
|
88
|
+
def construct_export_pattern(path, source, translation)
|
89
|
+
pattern_regexp = translate_pattern_to_regexp(source)
|
90
|
+
if path.match(pattern_regexp)
|
91
|
+
double_asterisk = path.match(pattern_regexp)['double_asterisk']
|
92
|
+
translation = translation.sub('**', double_asterisk)
|
93
|
+
end
|
94
|
+
|
95
|
+
export_pattern = translation.split('/').reject(&:empty?).join('/').insert(0, '/')
|
96
|
+
|
97
|
+
return export_pattern
|
98
|
+
end
|
99
|
+
|
100
|
+
# Translate a glob pattern to a regular expression
|
101
|
+
#
|
102
|
+
def translate_pattern_to_regexp(pat)
|
103
|
+
i = 0
|
104
|
+
n = pat.size
|
105
|
+
res = ''
|
106
|
+
while i < n
|
107
|
+
c = pat[i]
|
108
|
+
i = i + 1
|
109
|
+
if c == '*'
|
110
|
+
j = i
|
111
|
+
if j < n and pat[j] == '*'
|
112
|
+
res << '(?<double_asterisk>.*)'
|
113
|
+
i = j + 1
|
114
|
+
else
|
115
|
+
res << '(.*)'
|
116
|
+
end
|
117
|
+
elsif c == '?'
|
118
|
+
res << '.'
|
119
|
+
else
|
120
|
+
res << Regexp.escape(c)
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
return Regexp.new(res)
|
125
|
+
end
|
126
|
+
|
83
127
|
def android_locale_code(locale_code)
|
84
128
|
locale_code = case locale_code
|
85
129
|
when 'he-IL' then 'iw-IL'
|
@@ -155,7 +199,7 @@ include GLI::App
|
|
155
199
|
version Crowdin::CLI::VERSION
|
156
200
|
|
157
201
|
program_desc 'is a command line tool that allows you to manage and synchronize your localization resources with Crowdin project'
|
158
|
-
program_long_desc 'This tool requires configuration file to be created. See http://crowdin.net/page/cli-
|
202
|
+
program_long_desc 'This tool requires configuration file to be created. See http://crowdin.net/page/cli-tool#configuration-file for more details.'
|
159
203
|
sort_help :manually # help commands are ordered in the order declared
|
160
204
|
wrap_help_text :to_terminal
|
161
205
|
|
@@ -199,7 +243,7 @@ EOS
|
|
199
243
|
|
200
244
|
@config['files'].each do |file|
|
201
245
|
get_invalid_placeholders(file['translation']).each do |placeholder|
|
202
|
-
puts "Warning: #{placeholder} is not valid variable supported by Crowdin. See http://crowdin.net/page/cli-
|
246
|
+
puts "Warning: #{placeholder} is not valid variable supported by Crowdin. See http://crowdin.net/page/cli-tool#configuration-file for more details."
|
203
247
|
end
|
204
248
|
|
205
249
|
if File.exist?("#{@base_path}#{file['source']}")
|
@@ -216,10 +260,7 @@ EOS
|
|
216
260
|
dest = source.sub("#{@base_path}", '') # relative path in Crowdin
|
217
261
|
dest_files << dest
|
218
262
|
|
219
|
-
|
220
|
-
|
221
|
-
diff = (dest.split('/') - file_pattern.split('/')).join('/')
|
222
|
-
export_pattern = file['translation'].sub('**', diff)
|
263
|
+
export_pattern = construct_export_pattern(dest, file['source'], file['translation'])
|
223
264
|
|
224
265
|
local_file = { dest: dest, source: source, export_pattern: export_pattern }
|
225
266
|
local_file.merge!({ sheme: file['scheme'] }) if file.has_key?('scheme')
|
@@ -231,7 +272,7 @@ EOS
|
|
231
272
|
end # @config['files']
|
232
273
|
|
233
274
|
if dest_files.empty?
|
234
|
-
exit_now!("nothing to upload. See http://crowdin.net/page/cli-
|
275
|
+
exit_now!("nothing to upload. See http://crowdin.net/page/cli-tool#configuration-file for more details.")
|
235
276
|
end
|
236
277
|
|
237
278
|
common_dir = find_common_directory_path(dest_files)
|
@@ -313,7 +354,6 @@ EOS
|
|
313
354
|
c.desc 'Automatically approve uploaded translations'
|
314
355
|
c.switch ['auto-approve-imported']
|
315
356
|
|
316
|
-
|
317
357
|
c.action do |global_options, options, args|
|
318
358
|
params = {}
|
319
359
|
params[:import_duplicates] = options['import-dublicates'] ? 1 : 0
|
@@ -343,7 +383,7 @@ EOS
|
|
343
383
|
|
344
384
|
@config['files'].each do |file|
|
345
385
|
get_invalid_placeholders(file['translation']).each do |placeholder|
|
346
|
-
puts "Warning: #{placeholder} is not valid variable supported by Crowdin. See http://crowdin.net/page/cli-
|
386
|
+
puts "Warning: #{placeholder} is not valid variable supported by Crowdin. See http://crowdin.net/page/cli-tool#configuration-file for more details."
|
347
387
|
end
|
348
388
|
|
349
389
|
languages_mapping = file['languages_mapping']
|
@@ -361,10 +401,7 @@ EOS
|
|
361
401
|
dest = source.sub("#{@base_path}", '') # relative path in Crowdin
|
362
402
|
dest_files << dest
|
363
403
|
|
364
|
-
|
365
|
-
|
366
|
-
diff = (dest.split('/') - file_pattern.split('/')).join('/')
|
367
|
-
export_pattern = file['translation'].sub('**', diff) # !!!
|
404
|
+
export_pattern = construct_export_pattern(dest, file['source'], file['translation'])
|
368
405
|
|
369
406
|
translation_languages.each do |lang|
|
370
407
|
source = export_pattern_to_path(dest, export_pattern, lang, languages_mapping)
|
@@ -376,7 +413,7 @@ EOS
|
|
376
413
|
end # @config['files']
|
377
414
|
|
378
415
|
if dest_files.empty?
|
379
|
-
exit_now!("Warning: nothing to upload. See http://crowdin.net/page/cli-
|
416
|
+
exit_now!("Warning: nothing to upload. See http://crowdin.net/page/cli-tool#configuration-file for more details.")
|
380
417
|
end
|
381
418
|
|
382
419
|
common_dir = find_common_directory_path(dest_files)
|
@@ -462,11 +499,8 @@ command :download do |c|
|
|
462
499
|
Dir.glob("#{@base_path}#{file['source']}").each do |source|
|
463
500
|
dest = source.sub("#{@base_path}", '') # relative path in Crowdin
|
464
501
|
|
465
|
-
|
466
|
-
|
467
|
-
diff = (dest.split('/') - file_pattern.split('/')).join('/')
|
468
|
-
export_pattern = file['translation'].sub('**', diff)
|
469
|
-
|
502
|
+
export_pattern = construct_export_pattern(dest, file['source'], file['translation'])
|
503
|
+
|
470
504
|
translation_languages.each do |lang|
|
471
505
|
zipped_file = export_pattern_to_path(dest, export_pattern, lang)
|
472
506
|
local_file = export_pattern_to_path(dest, export_pattern, lang, languages_mapping)
|
@@ -507,7 +541,7 @@ pre do |global ,command, options, args|
|
|
507
541
|
exit_now! <<EOS
|
508
542
|
Configuration file misses required option `#{key}`
|
509
543
|
|
510
|
-
See http://crowdin.net/page/cli-
|
544
|
+
See http://crowdin.net/page/cli-tool#configuration-file for more details
|
511
545
|
EOS
|
512
546
|
end
|
513
547
|
end
|
@@ -516,7 +550,7 @@ EOS
|
|
516
550
|
exit_now! <<EOS
|
517
551
|
Configuration file misses required section `files`
|
518
552
|
|
519
|
-
See http://crowdin.net/page/cli-
|
553
|
+
See http://crowdin.net/page/cli-tool#configuration-file for more details
|
520
554
|
EOS
|
521
555
|
end
|
522
556
|
|
@@ -532,6 +566,17 @@ EOS
|
|
532
566
|
@config['files'].each do |file|
|
533
567
|
file['source'] = '/' + file['source'] unless file['source'].start_with?('/')
|
534
568
|
file['translation'] = '/' + file['translation'] unless file['translation'].start_with?('/')
|
569
|
+
|
570
|
+
if file['source'].scan('**').size > 1
|
571
|
+
exit_now! <<EOS
|
572
|
+
Pattern `#{file['source']}` is not valid. The mask `**` can be used only once in the source pattern.
|
573
|
+
EOS
|
574
|
+
elsif file['source'].scan('**').size == 1 and !file['source'].match(/\/\*\*\//)
|
575
|
+
exit_now! <<EOS
|
576
|
+
Pattern `#{file['source']}` is not valid. The mask `**` must be surrounded by backslashes `/` in the source pattern.
|
577
|
+
EOS
|
578
|
+
end
|
579
|
+
|
535
580
|
end
|
536
581
|
|
537
582
|
if @config['base_path']
|
data/lib/crowdin-cli/version.rb
CHANGED
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.1.
|
4
|
+
version: 0.1.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crowdin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-04-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -86,14 +86,14 @@ dependencies:
|
|
86
86
|
requirements:
|
87
87
|
- - '>='
|
88
88
|
- !ruby/object:Gem::Version
|
89
|
-
version: 0.0.
|
89
|
+
version: 0.0.11
|
90
90
|
type: :runtime
|
91
91
|
prerelease: false
|
92
92
|
version_requirements: !ruby/object:Gem::Requirement
|
93
93
|
requirements:
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
|
-
version: 0.0.
|
96
|
+
version: 0.0.11
|
97
97
|
description:
|
98
98
|
email:
|
99
99
|
- support@crowdin.net
|