crowdin-cli 0.3.0 → 0.3.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/crowdin-cli +113 -112
- data/lib/crowdin-cli/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 7d02585361bf7674f7181d11121b4f59cb8dda75
|
4
|
+
data.tar.gz: bbd79e95600a053c960fcec11faa656acf5331b7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 23740c03b14c40a649ff0566f51d1edb1c87d51877e3fe3b6b91f7b1abe55c19742ca05fb48551c4248fa6c30b0283f0a40e159352905c51241cd9ed772b6792
|
7
|
+
data.tar.gz: b1c8d3312553463b9098db3f7624c51387b34753d0320b57c14baa640238ddfab72a1fe0d1ba73b807ecce64f37ad60ca62019b3803ced4a8af83fa355c726ef
|
data/bin/crowdin-cli
CHANGED
@@ -1,4 +1,5 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
+
# encoding: utf-8
|
2
3
|
|
3
4
|
require 'pp'
|
4
5
|
require 'find'
|
@@ -602,6 +603,118 @@ EOS
|
|
602
603
|
|
603
604
|
end
|
604
605
|
|
606
|
+
desc I18n.t('app.commands.download.desc')
|
607
|
+
#arg_name 'Describe arguments to download here'
|
608
|
+
command :download do |c|
|
609
|
+
|
610
|
+
c.desc I18n.t('app.commands.download.flags.language.desc')
|
611
|
+
c.long_desc I18n.t('app.commands.download.flags.language.long_desc')
|
612
|
+
c.arg_name 'language_code'
|
613
|
+
c.flag [:l, :language], :default_value => 'all'
|
614
|
+
|
615
|
+
c.action do |global_options ,options, args|
|
616
|
+
language = options[:language]
|
617
|
+
|
618
|
+
supported_languages = @crowdin.supported_languages
|
619
|
+
|
620
|
+
project_info = @crowdin.project_info
|
621
|
+
|
622
|
+
if language == 'all'
|
623
|
+
project_languages = project_info['languages'].collect{ |h| h['code'] }
|
624
|
+
|
625
|
+
if @jipt_language
|
626
|
+
if supported_languages.find { |lang| lang['crowdin_code'] == @jipt_language }
|
627
|
+
project_languages << @jipt_language # crowdin_language_code
|
628
|
+
else
|
629
|
+
exit_now!("invalid jipt language `#{@jipt_language}`")
|
630
|
+
end
|
631
|
+
end
|
632
|
+
else
|
633
|
+
if project_languages.include?(language)
|
634
|
+
project_languages = [] << language
|
635
|
+
else
|
636
|
+
exit_now!("language '#{language}' doesn't exist in a project")
|
637
|
+
end
|
638
|
+
end
|
639
|
+
|
640
|
+
# use export API method before to download the most recent translations
|
641
|
+
@crowdin.export_translations
|
642
|
+
|
643
|
+
source_language = project_info['details']['source_language']['code']
|
644
|
+
source_language = supported_languages.find { |lang| lang['crowdin_code'] == source_language }
|
645
|
+
|
646
|
+
translation_languages = supported_languages.select { |lang| project_languages.include?(lang['crowdin_code']) }
|
647
|
+
|
648
|
+
# keys is all possible files in .ZIP archive
|
649
|
+
# values is resulted local files
|
650
|
+
downloadable_files_hash = {}
|
651
|
+
|
652
|
+
@config['files'].each do |file|
|
653
|
+
languages_mapping = file['languages_mapping'] # Hash or NilClass
|
654
|
+
|
655
|
+
ignores = file['ignore'] || []
|
656
|
+
|
657
|
+
# CSV files only (default: false)
|
658
|
+
multilingual_spreadsheet = file['multilingual_spreadsheet'] || false
|
659
|
+
|
660
|
+
if multilingual_spreadsheet
|
661
|
+
file_translation_languages = [] << source_language
|
662
|
+
else
|
663
|
+
file_translation_languages = translation_languages
|
664
|
+
end
|
665
|
+
|
666
|
+
if File.exists?(File.join(@base_path, file['source']))
|
667
|
+
dest = file['source'].sub("#{@base_path}", '')
|
668
|
+
|
669
|
+
file_translation_languages.each do |lang|
|
670
|
+
zipped_file = export_pattern_to_path(dest, file['translation'], lang)
|
671
|
+
zipped_file.sub!(/^\//, '')
|
672
|
+
local_file = export_pattern_to_path(dest, file['translation'], lang, languages_mapping)
|
673
|
+
downloadable_files_hash[zipped_file] = local_file
|
674
|
+
end
|
675
|
+
|
676
|
+
else
|
677
|
+
Find.find(@base_path) do |source_path|
|
678
|
+
dest = source_path.sub(@base_path, '') # relative path in Crowdin
|
679
|
+
|
680
|
+
if File.directory?(source_path)
|
681
|
+
if ignores.any? { |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
|
682
|
+
Find.prune # Don't look any further into this directory
|
683
|
+
else
|
684
|
+
next
|
685
|
+
end
|
686
|
+
elsif File.fnmatch?(file['source'], dest, File::FNM_PATHNAME)
|
687
|
+
next if ignores.any? { |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
|
688
|
+
|
689
|
+
export_pattern = construct_export_pattern(dest, file['source'], file['translation'])
|
690
|
+
|
691
|
+
file_translation_languages.each do |lang|
|
692
|
+
zipped_file = export_pattern_to_path(dest, export_pattern, lang)
|
693
|
+
zipped_file.sub!(/^\//, '')
|
694
|
+
local_file = export_pattern_to_path(dest, export_pattern, lang, languages_mapping)
|
695
|
+
downloadable_files_hash[zipped_file] = local_file
|
696
|
+
end
|
697
|
+
|
698
|
+
end
|
699
|
+
end # Find
|
700
|
+
end # if
|
701
|
+
end # @config['files']
|
702
|
+
|
703
|
+
##
|
704
|
+
tempfile = Tempfile.new(language)
|
705
|
+
zipfile_name = tempfile.path
|
706
|
+
begin
|
707
|
+
@crowdin.download_translation(language, output: zipfile_name)
|
708
|
+
|
709
|
+
unzip_file_with_translations(zipfile_name, @base_path, downloadable_files_hash)
|
710
|
+
ensure
|
711
|
+
tempfile.close
|
712
|
+
tempfile.unlink # delete the tempfile
|
713
|
+
end
|
714
|
+
|
715
|
+
end # action
|
716
|
+
end # download
|
717
|
+
|
605
718
|
desc I18n.t('app.commands.list.desc')
|
606
719
|
long_desc I18n.t('app.commands.list.long_desc')
|
607
720
|
command :list do |ls_cmd|
|
@@ -759,118 +872,6 @@ command :list do |ls_cmd|
|
|
759
872
|
#ls_cmd.default_command :project
|
760
873
|
end # list
|
761
874
|
|
762
|
-
desc I18n.t('app.commands.download.desc')
|
763
|
-
#arg_name 'Describe arguments to download here'
|
764
|
-
command :download do |c|
|
765
|
-
|
766
|
-
c.desc I18n.t('app.commands.download.flags.language.desc')
|
767
|
-
c.long_desc I18n.t('app.commands.download.flags.language.long_desc')
|
768
|
-
c.arg_name 'language_code'
|
769
|
-
c.flag [:l, :language], :default_value => 'all'
|
770
|
-
|
771
|
-
c.action do |global_options ,options, args|
|
772
|
-
language = options[:language]
|
773
|
-
|
774
|
-
supported_languages = @crowdin.supported_languages
|
775
|
-
|
776
|
-
project_info = @crowdin.project_info
|
777
|
-
|
778
|
-
if language == 'all'
|
779
|
-
project_languages = project_info['languages'].collect{ |h| h['code'] }
|
780
|
-
|
781
|
-
if @jipt_language
|
782
|
-
if supported_languages.find { |lang| lang['crowdin_code'] == @jipt_language }
|
783
|
-
project_languages << @jipt_language # crowdin_language_code
|
784
|
-
else
|
785
|
-
exit_now!("invalid jipt language `#{@jipt_language}`")
|
786
|
-
end
|
787
|
-
end
|
788
|
-
else
|
789
|
-
if project_languages.include?(language)
|
790
|
-
project_languages = [] << language
|
791
|
-
else
|
792
|
-
exit_now!("language '#{language}' doesn't exist in a project")
|
793
|
-
end
|
794
|
-
end
|
795
|
-
|
796
|
-
# use export API method before to download the most recent translations
|
797
|
-
@crowdin.export_translations
|
798
|
-
|
799
|
-
source_language = project_info['details']['source_language']['code']
|
800
|
-
source_language = supported_languages.find { |lang| lang['crowdin_code'] == source_language }
|
801
|
-
|
802
|
-
translation_languages = supported_languages.select { |lang| project_languages.include?(lang['crowdin_code']) }
|
803
|
-
|
804
|
-
# keys is all possible files in .ZIP archive
|
805
|
-
# values is resulted local files
|
806
|
-
downloadable_files_hash = {}
|
807
|
-
|
808
|
-
@config['files'].each do |file|
|
809
|
-
languages_mapping = file['languages_mapping'] # Hash or NilClass
|
810
|
-
|
811
|
-
ignores = file['ignore'] || []
|
812
|
-
|
813
|
-
# CSV files only (default: false)
|
814
|
-
multilingual_spreadsheet = file['multilingual_spreadsheet'] || false
|
815
|
-
|
816
|
-
if multilingual_spreadsheet
|
817
|
-
file_translation_languages = [] << source_language
|
818
|
-
else
|
819
|
-
file_translation_languages = translation_languages
|
820
|
-
end
|
821
|
-
|
822
|
-
if File.exists?(File.join(@base_path, file['source']))
|
823
|
-
dest = file['source'].sub("#{@base_path}", '')
|
824
|
-
|
825
|
-
file_translation_languages.each do |lang|
|
826
|
-
zipped_file = export_pattern_to_path(dest, file['translation'], lang)
|
827
|
-
zipped_file.sub!(/^\//, '')
|
828
|
-
local_file = export_pattern_to_path(dest, file['translation'], lang, languages_mapping)
|
829
|
-
downloadable_files_hash[zipped_file] = local_file
|
830
|
-
end
|
831
|
-
|
832
|
-
else
|
833
|
-
Find.find(@base_path) do |source_path|
|
834
|
-
dest = source_path.sub(@base_path, '') # relative path in Crowdin
|
835
|
-
|
836
|
-
if File.directory?(source_path)
|
837
|
-
if ignores.any? { |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
|
838
|
-
Find.prune # Don't look any further into this directory
|
839
|
-
else
|
840
|
-
next
|
841
|
-
end
|
842
|
-
elsif File.fnmatch?(file['source'], dest, File::FNM_PATHNAME)
|
843
|
-
next if ignores.any? { |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
|
844
|
-
|
845
|
-
export_pattern = construct_export_pattern(dest, file['source'], file['translation'])
|
846
|
-
|
847
|
-
file_translation_languages.each do |lang|
|
848
|
-
zipped_file = export_pattern_to_path(dest, export_pattern, lang)
|
849
|
-
zipped_file.sub!(/^\//, '')
|
850
|
-
local_file = export_pattern_to_path(dest, export_pattern, lang, languages_mapping)
|
851
|
-
downloadable_files_hash[zipped_file] = local_file
|
852
|
-
end
|
853
|
-
|
854
|
-
end
|
855
|
-
end # Find
|
856
|
-
end # if
|
857
|
-
end # @config['files']
|
858
|
-
|
859
|
-
##
|
860
|
-
tempfile = Tempfile.new(language)
|
861
|
-
zipfile_name = tempfile.path
|
862
|
-
begin
|
863
|
-
@crowdin.download_translation(language, output: zipfile_name)
|
864
|
-
|
865
|
-
unzip_file_with_translations(zipfile_name, @base_path, downloadable_files_hash)
|
866
|
-
ensure
|
867
|
-
tempfile.close
|
868
|
-
tempfile.unlink # delete the tempfile
|
869
|
-
end
|
870
|
-
|
871
|
-
end # action
|
872
|
-
end # download
|
873
|
-
|
874
875
|
pre do |globals ,command, options, args|
|
875
876
|
# Pre logic here
|
876
877
|
# Return true to proceed; false to abourt and not call the
|
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.3.
|
4
|
+
version: 0.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crowdin
|
@@ -14,42 +14,42 @@ dependencies:
|
|
14
14
|
name: rake
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
19
|
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rdoc
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
30
30
|
requirements:
|
31
|
-
- - "
|
31
|
+
- - ">="
|
32
32
|
- !ruby/object:Gem::Version
|
33
33
|
version: '0'
|
34
34
|
type: :development
|
35
35
|
prerelease: false
|
36
36
|
version_requirements: !ruby/object:Gem::Requirement
|
37
37
|
requirements:
|
38
|
-
- - "
|
38
|
+
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
41
|
- !ruby/object:Gem::Dependency
|
42
42
|
name: aruba
|
43
43
|
requirement: !ruby/object:Gem::Requirement
|
44
44
|
requirements:
|
45
|
-
- - "
|
45
|
+
- - ">="
|
46
46
|
- !ruby/object:Gem::Version
|
47
47
|
version: '0'
|
48
48
|
type: :development
|
49
49
|
prerelease: false
|
50
50
|
version_requirements: !ruby/object:Gem::Requirement
|
51
51
|
requirements:
|
52
|
-
- - "
|
52
|
+
- - ">="
|
53
53
|
- !ruby/object:Gem::Version
|
54
54
|
version: '0'
|
55
55
|
- !ruby/object:Gem::Dependency
|