crowdin-cli 0.1.6 → 0.1.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/bin/crowdin-cli +75 -64
- data/lib/crowdin-cli.rb +1 -0
- data/lib/crowdin-cli/version.rb +1 -1
- data/locales/en.yml +57 -0
- metadata +19 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a3ff7f5862e6cdfc6f19faa22a7c6e9d2a1aba5c
|
4
|
+
data.tar.gz: e8f7cc6f44b5a4109f4ef5405e1bb914c339344a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7e6356eee6ca194d2e6a29c2082b60ff1a04761076718d48c499bd6a9b3698eacd68ca6a42442774e7fe733e82f762687a4b346d7d4d997d5fb01f144cef685d
|
7
|
+
data.tar.gz: feb7abd1dccf237b26b65b609828de63a5d33d07c6a884edc16540ef97fc3f04bbc1e967ae96a3632d5a9431c50520b10cfdfa2cf612682e0d64c4f2a69f3733
|
data/README.md
CHANGED
@@ -255,4 +255,4 @@ Author: Anton Maminov (anton.maminov@gmail.com)
|
|
255
255
|
|
256
256
|
Copyright: 2012-2013 [Crowdin.net](http://crowdin.net/)
|
257
257
|
|
258
|
-
This
|
258
|
+
This project is licensed under the MIT license, a copy of which can be found in the LICENSE file.
|
data/bin/crowdin-cli
CHANGED
@@ -5,6 +5,11 @@ require 'crowdin-cli'
|
|
5
5
|
|
6
6
|
# GLI_DEBUG=true bundle exec bin/crowdin-cli
|
7
7
|
|
8
|
+
# Setup i18n
|
9
|
+
# tell the I18n library where to find your translations
|
10
|
+
I18n.load_path += Dir[Pathname(__FILE__).dirname.expand_path + '../locales/*.yml']
|
11
|
+
I18n.locale = :en
|
12
|
+
|
8
13
|
# Return +hierarchy+ of directories and files in Crowdin project
|
9
14
|
#
|
10
15
|
# +files+ - basically, it's project files details from API method `project_info`
|
@@ -72,7 +77,7 @@ def export_pattern_to_path(path, export_pattern, lang, languages_mapping = nil)
|
|
72
77
|
placeholders = pattern.inject([]){ |memo, h| memo << h.first[/%(.*)%/, 1] }
|
73
78
|
|
74
79
|
unless languages_mapping.nil?
|
75
|
-
pattern = Hash[pattern.map{|placeholder, str| [
|
80
|
+
pattern = Hash[pattern.map{ |placeholder, str| [
|
76
81
|
placeholder,
|
77
82
|
(languages_mapping[placeholder[/%(.*)%/, 1]][lang['crowdin_code']] rescue nil) || str]
|
78
83
|
}]
|
@@ -181,7 +186,7 @@ def unzip_file(zip, dest, files_list)
|
|
181
186
|
if file
|
182
187
|
f_path = File.join(dest, file)
|
183
188
|
FileUtils.mkdir_p(File.dirname(f_path))
|
184
|
-
puts "Download:
|
189
|
+
puts "Download: `#{file}'"
|
185
190
|
zip_file.extract(f, f_path)
|
186
191
|
else
|
187
192
|
unmatched_files << f
|
@@ -201,33 +206,30 @@ include GLI::App
|
|
201
206
|
|
202
207
|
version Crowdin::CLI::VERSION
|
203
208
|
|
204
|
-
|
205
|
-
|
209
|
+
subcommand_option_handling :normal
|
210
|
+
|
211
|
+
program_desc I18n.t('app.desc')
|
212
|
+
program_long_desc I18n.t('app.long_desc')
|
206
213
|
sort_help :manually # help commands are ordered in the order declared
|
207
214
|
wrap_help_text :to_terminal
|
208
215
|
|
209
|
-
desc '
|
210
|
-
switch [:v, :
|
216
|
+
desc I18n.t('app.switches.verbose.desc')
|
217
|
+
switch [:verbose, :v], :negatable => false
|
211
218
|
|
212
|
-
desc '
|
219
|
+
desc I18n.t('app.flags.config.desc')
|
213
220
|
default_value File.join(Dir.pwd, 'crowdin.yaml')
|
214
221
|
arg_name '<s>'
|
215
|
-
flag [:c
|
216
|
-
|
217
|
-
desc 'Allows you to upload source files and existing translations to Crowdin project'
|
218
|
-
long_desc 'This command is used to upload source files and translations to Crowdin. This command is used in combination with sub-commands `sources` and `translations`.'
|
222
|
+
flag [:config,:c]
|
219
223
|
|
224
|
+
desc I18n.t('app.commands.upload.desc')
|
225
|
+
long_desc I18n.t('app.commands.upload.long_desc')
|
220
226
|
command :upload do |c|
|
221
227
|
|
222
|
-
c.desc '
|
223
|
-
c.long_desc
|
224
|
-
Upload source files to Crowdin project. If there are new localization files locally they will be added to Crowdin project.
|
225
|
-
Othervice files will be updated (if no --no-auto-update option specified).
|
226
|
-
EOS
|
227
|
-
|
228
|
+
c.desc I18n.t('app.commands.upload.commands.sources.desc')
|
229
|
+
c.long_desc I18n.t('app.commands.upload.commands.sources.long_desc')
|
228
230
|
c.command :sources do |c|
|
229
231
|
|
230
|
-
c.desc '
|
232
|
+
c.desc I18n.t('app.commands.upload.commands.sources.switches.auto_update.desc')
|
231
233
|
c.switch ['auto-update']
|
232
234
|
|
233
235
|
c.action do |global_options, options, args|
|
@@ -276,7 +278,11 @@ EOS
|
|
276
278
|
end # @config['files']
|
277
279
|
|
278
280
|
if dest_files.empty?
|
279
|
-
exit_now!
|
281
|
+
exit_now! <<EOS
|
282
|
+
No source files to upload.
|
283
|
+
Check your configuration file to ensure that they contain valid directives.
|
284
|
+
See http://crowdin.net/page/cli-tool#configuration-file for more details.
|
285
|
+
EOS
|
280
286
|
end
|
281
287
|
|
282
288
|
common_dir = @preserve_hierarchy ? '' : find_common_directory_path(dest_files)
|
@@ -334,28 +340,22 @@ EOS
|
|
334
340
|
end # action
|
335
341
|
end # command
|
336
342
|
|
337
|
-
c.desc 'upload
|
338
|
-
c.long_desc
|
339
|
-
Upload existing translations to Crowdin.
|
340
|
-
See below available options that can be used in combination with this command.
|
341
|
-
If no options specified uploaded translations will be not approved,
|
342
|
-
imported to Crowdin project even if they are duplicated and imported even they are equal to souce string.
|
343
|
-
(In many localization formats they can be considered as not actually translations).
|
344
|
-
EOS
|
343
|
+
c.desc I18n.t('app.commands.upload.commands.translations.desc')
|
344
|
+
c.long_desc I18n.t('app.commands.upload.commands.translations.long_desc')
|
345
345
|
c.command :translations do |c|
|
346
346
|
|
347
|
-
c.desc '
|
347
|
+
c.desc I18n.t('app.commands.upload.commands.translations.flags.language.desc')
|
348
348
|
c.default_value 'all'
|
349
349
|
c.arg_name 'crowdin_language_code'
|
350
|
-
c.flag [:
|
350
|
+
c.flag [:language, :l]
|
351
351
|
|
352
|
-
c.desc '
|
352
|
+
c.desc I18n.t('app.commands.upload.commands.translations.switches.import_duplicates.desc')
|
353
353
|
c.switch ['import-duplicates']
|
354
354
|
|
355
|
-
c.desc '
|
355
|
+
c.desc I18n.t('app.commands.upload.commands.translations.switches.import_eq_suggestions.desc')
|
356
356
|
c.switch ['import-eq-suggestions']
|
357
357
|
|
358
|
-
c.desc '
|
358
|
+
c.desc I18n.t('app.commands.upload.commands.translations.switches.auto_approve_imported.desc')
|
359
359
|
c.switch ['auto-approve-imported']
|
360
360
|
|
361
361
|
c.action do |global_options, options, args|
|
@@ -370,10 +370,13 @@ EOS
|
|
370
370
|
|
371
371
|
remote_project_tree = get_remote_files_hierarchy(project_info['files'])
|
372
372
|
|
373
|
-
|
374
|
-
|
375
|
-
|
376
|
-
|
373
|
+
project_languages = project_info['languages'].collect{ |h| h['code'] }
|
374
|
+
if language != 'all'
|
375
|
+
if project_languages.include?(language)
|
376
|
+
project_languages = [] << language
|
377
|
+
else
|
378
|
+
exit_now!("language '#{language}' doesn't exist in a project")
|
379
|
+
end
|
377
380
|
end
|
378
381
|
|
379
382
|
supported_languages = @crowdin.supported_languages
|
@@ -417,14 +420,18 @@ EOS
|
|
417
420
|
end # @config['files']
|
418
421
|
|
419
422
|
if dest_files.empty?
|
420
|
-
exit_now!
|
423
|
+
exit_now! <<EOS
|
424
|
+
No translation files to upload.
|
425
|
+
Check your configuration file to ensure that they contain valid directives.
|
426
|
+
See http://crowdin.net/page/cli-tool#configuration-file for more details.
|
427
|
+
EOS
|
421
428
|
end
|
422
429
|
|
423
430
|
common_dir = @preserve_hierarchy ? '' : find_common_directory_path(dest_files)
|
424
431
|
|
425
|
-
translated_files.
|
432
|
+
translated_files.each_pair do |language, files|
|
426
433
|
files.each do |file|
|
427
|
-
file[:dest].sub
|
434
|
+
file[:dest] = file[:dest].sub(common_dir, '')
|
428
435
|
|
429
436
|
if remote_project_tree[:files].include?(file[:dest])
|
430
437
|
if File.exist?(file[:source])
|
@@ -433,9 +440,9 @@ EOS
|
|
433
440
|
resp = @crowdin.upload_translation([] << file, language, params)
|
434
441
|
case resp['files'].first[1]
|
435
442
|
when 'skipped'
|
436
|
-
puts "\rUploading translation `#{file[:source].sub(@base_path, '')}' - Skipped"
|
443
|
+
puts "\rUploading translation file `#{file[:source].sub(@base_path, '')}' - Skipped"
|
437
444
|
when 'uploaded'
|
438
|
-
puts "\rUploading translation `#{file[:source].sub(@base_path, '')}' - OK"
|
445
|
+
puts "\rUploading translation file `#{file[:source].sub(@base_path, '')}' - OK"
|
439
446
|
end
|
440
447
|
else
|
441
448
|
puts "Warning: Local file `#{file[:source]}' does not exists"
|
@@ -444,7 +451,6 @@ EOS
|
|
444
451
|
# if source file not exist, don't upload translation
|
445
452
|
puts "Warning: Skip `#{file[:source].sub(@base_path, '')}'"
|
446
453
|
end
|
447
|
-
|
448
454
|
end
|
449
455
|
end
|
450
456
|
|
@@ -453,29 +459,33 @@ EOS
|
|
453
459
|
|
454
460
|
end
|
455
461
|
|
456
|
-
desc '
|
462
|
+
desc I18n.t('app.commands.download.desc')
|
457
463
|
#arg_name 'Describe arguments to download here'
|
458
464
|
command :download do |c|
|
459
465
|
|
460
|
-
c.desc '
|
466
|
+
c.desc I18n.t('app.commands.download.flags.language.desc')
|
461
467
|
c.arg_name 'language_code'
|
462
|
-
c.flag :
|
468
|
+
c.flag [:language, :l], :default_value => 'all'
|
463
469
|
|
464
470
|
c.action do |global_options ,options, args|
|
465
|
-
# use export API method before to download the most recent translations
|
466
|
-
@crowdin.export_translations
|
467
|
-
|
468
471
|
language = options[:language]
|
472
|
+
|
469
473
|
project_info = @crowdin.project_info
|
470
474
|
|
471
475
|
remote_project_tree = get_remote_files_hierarchy(project_info['files'])
|
472
476
|
|
473
|
-
|
474
|
-
|
475
|
-
|
476
|
-
|
477
|
+
project_languages = project_info['languages'].collect{ |h| h['code'] }
|
478
|
+
if language != 'all'
|
479
|
+
if project_languages.include?(language)
|
480
|
+
project_languages = [] << language
|
481
|
+
else
|
482
|
+
exit_now!("language '#{language}' doesn't exist in a project")
|
483
|
+
end
|
477
484
|
end
|
478
485
|
|
486
|
+
# use export API method before to download the most recent translations
|
487
|
+
@crowdin.export_translations
|
488
|
+
|
479
489
|
supported_languages = @crowdin.supported_languages
|
480
490
|
translation_languages = supported_languages.select{ |lang| project_languages.include?(lang['crowdin_code']) }
|
481
491
|
|
@@ -504,7 +514,7 @@ command :download do |c|
|
|
504
514
|
dest = source.sub("#{@base_path}", '') # relative path in Crowdin
|
505
515
|
|
506
516
|
export_pattern = construct_export_pattern(dest, file['source'], file['translation'])
|
507
|
-
|
517
|
+
|
508
518
|
translation_languages.each do |lang|
|
509
519
|
zipped_file = export_pattern_to_path(dest, export_pattern, lang)
|
510
520
|
local_file = export_pattern_to_path(dest, export_pattern, lang, languages_mapping)
|
@@ -520,7 +530,7 @@ command :download do |c|
|
|
520
530
|
file = Tempfile.new(language)
|
521
531
|
path = file.path
|
522
532
|
begin
|
523
|
-
@crowdin.download_translation(language, :
|
533
|
+
@crowdin.download_translation(language, output: path)
|
524
534
|
unzip_file(path, @base_path, downloadable_files)
|
525
535
|
ensure
|
526
536
|
file.close
|
@@ -530,15 +540,15 @@ command :download do |c|
|
|
530
540
|
|
531
541
|
end
|
532
542
|
|
533
|
-
pre do |
|
543
|
+
pre do |globals ,command, options, args|
|
534
544
|
# Pre logic here
|
535
545
|
# Return true to proceed; false to abourt and not call the
|
536
546
|
# chosen command
|
537
547
|
# Use skips_pre before a command to skip this block
|
538
548
|
# on that command only
|
539
549
|
|
540
|
-
if File.exists?(
|
541
|
-
@config = YAML.load_file(
|
550
|
+
if File.exists?(globals[:config])
|
551
|
+
@config = YAML.load_file(globals[:config])
|
542
552
|
|
543
553
|
['api_key', 'project_identifier'].each do |key|
|
544
554
|
unless @config[key]
|
@@ -601,10 +611,11 @@ Warning: Configuration file misses parameter `base_path` that defines your proje
|
|
601
611
|
EOS
|
602
612
|
end
|
603
613
|
|
604
|
-
if @config['
|
605
|
-
@
|
614
|
+
if @config['remote_path']
|
615
|
+
@remote_path = @config['remote_path']
|
616
|
+
@remote_path = '/' + @remote_path unless @remote_path.start_with?('/')
|
606
617
|
else
|
607
|
-
@
|
618
|
+
@remote_path = ''
|
608
619
|
end
|
609
620
|
|
610
621
|
@preserve_hierarchy = false
|
@@ -621,7 +632,7 @@ EOS
|
|
621
632
|
end
|
622
633
|
end
|
623
634
|
|
624
|
-
Crowdin::API.log = Logger.new($stderr) if
|
635
|
+
Crowdin::API.log = Logger.new($stderr) if globals[:verbose]
|
625
636
|
@crowdin = Crowdin::API.new(api_key: @config['api_key'], project_id: @config['project_identifier'], base_url: @config['base_url'] || 'http://api.crowdin.net')
|
626
637
|
begin
|
627
638
|
@crowdin.project_info
|
@@ -631,15 +642,15 @@ EOS
|
|
631
642
|
exit_now!("Seems Crowdin server API URL is not valid. Please check the `base_url` parameter in the configuration file.")
|
632
643
|
end
|
633
644
|
|
634
|
-
#puts "Executing #{command.name}" if
|
645
|
+
#puts "Executing #{command.name}" if globals[:verbose]
|
635
646
|
true
|
636
647
|
end
|
637
648
|
|
638
|
-
post do |
|
649
|
+
post do |globals, command, options, args|
|
639
650
|
# Post logic here
|
640
651
|
# Use skips_post before a command to skip this
|
641
652
|
# block on that command only
|
642
|
-
#puts "Executed #{command.name}" if
|
653
|
+
#puts "Executed #{command.name}" if globals[:verbose]
|
643
654
|
end
|
644
655
|
|
645
656
|
on_error do |exception|
|
data/lib/crowdin-cli.rb
CHANGED
data/lib/crowdin-cli/version.rb
CHANGED
data/locales/en.yml
ADDED
@@ -0,0 +1,57 @@
|
|
1
|
+
en:
|
2
|
+
app:
|
3
|
+
desc: is a command line tool that allows you to manage and synchronize your localization resources with Crowdin project
|
4
|
+
long_desc: |
|
5
|
+
This tool requires configuration file to be created.
|
6
|
+
See http://crowdin.net/page/cli-tool#configuration-file for more details.
|
7
|
+
flags:
|
8
|
+
config:
|
9
|
+
desc: The configuration file
|
10
|
+
switches:
|
11
|
+
verbose:
|
12
|
+
desc: Be verbose
|
13
|
+
commands:
|
14
|
+
upload:
|
15
|
+
desc: Allows you to upload source files and existing translations to Crowdin project.
|
16
|
+
long_desc: |
|
17
|
+
This command is used to upload source files and translations to Crowdin.
|
18
|
+
This command is used in combination with sub-commands `sources` and `translations`
|
19
|
+
commands:
|
20
|
+
sources:
|
21
|
+
desc: safely upload source files to Crowdin
|
22
|
+
long_desc: |
|
23
|
+
Upload source files to Crowdin project.
|
24
|
+
If there are new localization files locally they will be added to Crowdin project.
|
25
|
+
Othervice files will be updated (if no --no-auto-update option specified).
|
26
|
+
switches:
|
27
|
+
auto_update:
|
28
|
+
desc: |
|
29
|
+
Defines whether to update source files in Crowdin project.
|
30
|
+
--no-auto-update is useful when you just want to upload new files without updating existing ones.
|
31
|
+
translations:
|
32
|
+
desc: upload existing translations to Crowdin project
|
33
|
+
long_desc: |
|
34
|
+
Upload existing translations to Crowdin.
|
35
|
+
See below available options that can be used in combination with this command.
|
36
|
+
If no options specified uploaded translations will be not approved,
|
37
|
+
imported to Crowdin project even if they are duplicated and imported even they are equal to souce string.
|
38
|
+
(In many localization formats they can be considered as not actually translations).
|
39
|
+
flags:
|
40
|
+
language:
|
41
|
+
desc: |
|
42
|
+
Defines what language upload translations to.
|
43
|
+
By default translations will be uploaded for all Crowdin project target languages
|
44
|
+
switches:
|
45
|
+
import_duplicates:
|
46
|
+
desc: Defines whether to add translation if there is the same translation already existing in Crowdin project
|
47
|
+
import_eq_suggestions:
|
48
|
+
desc: Defines whether to add translation if it is equal to source string in Crowdin project
|
49
|
+
auto_approve_imported:
|
50
|
+
desc: Automatically approve uploaded translations
|
51
|
+
download:
|
52
|
+
desc: Download latest translations from Crowdin and put them to the right places in your project
|
53
|
+
flags:
|
54
|
+
language:
|
55
|
+
desc: |
|
56
|
+
If the option is defined the translations will be downloaded for single specified language.
|
57
|
+
Othervice (by default) translations are downloaded for all languages
|
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.8
|
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-06-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - '>='
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 2.
|
61
|
+
version: 2.6.0
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - '>='
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 2.
|
68
|
+
version: 2.6.0
|
69
69
|
- !ruby/object:Gem::Dependency
|
70
70
|
name: rubyzip
|
71
71
|
requirement: !ruby/object:Gem::Requirement
|
@@ -94,6 +94,20 @@ dependencies:
|
|
94
94
|
- - '>='
|
95
95
|
- !ruby/object:Gem::Version
|
96
96
|
version: 0.0.11
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: i18n
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - '>='
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: 0.6.4
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: 0.6.4
|
97
111
|
description:
|
98
112
|
email:
|
99
113
|
- support@crowdin.net
|
@@ -105,6 +119,7 @@ files:
|
|
105
119
|
- bin/crowdin-cli
|
106
120
|
- lib/crowdin-cli/version.rb
|
107
121
|
- lib/crowdin-cli.rb
|
122
|
+
- locales/en.yml
|
108
123
|
- README.md
|
109
124
|
- LICENSE
|
110
125
|
homepage: https://github.com/crowdin/crowdin-cli/
|