crowdin-cli 0.4.1 → 0.4.2
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/LICENSE +1 -1
- data/README.md +42 -1
- data/bin/crowdin-cli +130 -83
- data/lib/crowdin-cli/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: daa20289026306a2008ed1ecc5ef161d7a6a4101
|
4
|
+
data.tar.gz: 77731ee49a71b4b23f04e2a5aa864821e1d2016b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 939acca8288fdee76d5f1cf7e4256d09f4b4ccc228f45c0e810d581cc88b860838f736410ce2363e54f01e35268fde2ed6b31deb3a263509d0dc959cb1a54a03
|
7
|
+
data.tar.gz: de55fe67aa2668fb7c34096804f795c414eb87181f024f3f955c0e60f33bae289d96bdb1b8e2cf2e35c3595479f2d7f842bb941ea63cdab76d0fbe23bf3dbf57
|
data/LICENSE
CHANGED
data/README.md
CHANGED
@@ -68,6 +68,8 @@ files:
|
|
68
68
|
* `%original_path%` - Take parent folders names in Crowdin project to build file path in resulted bundle
|
69
69
|
* `%file_extension%` - Original file extension
|
70
70
|
* `%file_name%` - File name without extension
|
71
|
+
* `%osx_code%` - OS X Locale identifier used to name ".lproj" directories
|
72
|
+
* `%osx_xliff%` - OS X Locale used to name xliff files (i.e. uk.xliff)
|
71
73
|
|
72
74
|
Example for Android projects:
|
73
75
|
```
|
@@ -120,6 +122,25 @@ files:
|
|
120
122
|
translation: /locale/%two_letters_code%/**/%original_file_name%
|
121
123
|
```
|
122
124
|
|
125
|
+
### API Credentials from environment variables
|
126
|
+
|
127
|
+
You could load the API Credentials from an environment variable, e.g.
|
128
|
+
|
129
|
+
```
|
130
|
+
api_key_env: 'CROWDIN_API_KEY'
|
131
|
+
project_identifier_env: 'CROWDIN_PROJECT_ID'
|
132
|
+
|
133
|
+
```
|
134
|
+
|
135
|
+
If mix, `api_key` and `project_identifier` have priority:
|
136
|
+
|
137
|
+
```
|
138
|
+
api_key_env: CROWDIN_API_KEY # Low priority
|
139
|
+
project_identifier_env: CROWDIN_PROJECT # Low priority
|
140
|
+
api_key: xxx # High priority
|
141
|
+
project_identifier: yyy # Hight priority
|
142
|
+
```
|
143
|
+
|
123
144
|
### Split project configuration and user credentials
|
124
145
|
|
125
146
|
The `crowdin.yaml` file contains project-specific configuration and user credentials(`api_key`, `project_identifier`).
|
@@ -192,6 +213,26 @@ base_path: /path/to/your/project
|
|
192
213
|
preserve_hierarchy: true
|
193
214
|
```
|
194
215
|
|
216
|
+
### [I Have No Idea How To Call This Section]
|
217
|
+
|
218
|
+
This add support for 2 optional parameters in the yaml file section: `dest` and `type`.
|
219
|
+
This is useful typically for some projects, where the uploaded name must be different so Crowdin can detect the type correctly.
|
220
|
+
`dest` allows you to specify a file name on Crowdin.
|
221
|
+
**NOTE**: `dest` only works for single files. Don't try to use it with patterns (multiple files).
|
222
|
+
|
223
|
+
Configuration sample is below:
|
224
|
+
|
225
|
+
```
|
226
|
+
files
|
227
|
+
-
|
228
|
+
source: '/conf/messages'
|
229
|
+
dest: '/messages.properties'
|
230
|
+
translation: '/conf/messages.%two_letters_code%'
|
231
|
+
type: 'properties'
|
232
|
+
|
233
|
+
|
234
|
+
```
|
235
|
+
|
195
236
|
### Escape quotes for `.properties` file format
|
196
237
|
|
197
238
|
Defines whether single quote should be escaped by another single quote or backslash in exported translations.
|
@@ -376,6 +417,6 @@ Tested with the following Ruby versions:
|
|
376
417
|
|
377
418
|
Author: Anton Maminov (anton.maminov@gmail.com)
|
378
419
|
|
379
|
-
Copyright: 2012-
|
420
|
+
Copyright: 2012-2015 [crowdin.com](http://crowdin.com/)
|
380
421
|
|
381
422
|
This project is licensed under the MIT license, a copy of which can be found in the LICENSE file.
|
data/bin/crowdin-cli
CHANGED
@@ -76,6 +76,7 @@ def export_pattern_to_path(path, export_pattern, lang, languages_mapping = nil)
|
|
76
76
|
'%locale_with_underscore%' => lang['locale'].gsub('-', '_'),
|
77
77
|
'%android_code%' => android_locale_code(lang['locale']),
|
78
78
|
'%osx_code%' => osx_language_code(lang['crowdin_code']) + '.lproj',
|
79
|
+
'%osx_xliff%' => osx_language_code(lang['crowdin_code']) + '.xliff',
|
79
80
|
}
|
80
81
|
|
81
82
|
placeholders = pattern.inject([]){ |memo, h| memo << h.first[/%(.*)%/, 1] }
|
@@ -203,6 +204,7 @@ def get_invalid_placeholders(export_pattern)
|
|
203
204
|
'%locale_with_underscore%',
|
204
205
|
'%android_code%',
|
205
206
|
'%osx_code%',
|
207
|
+
'%osx_liff%',
|
206
208
|
'%original_file_name%',
|
207
209
|
'%original_path%',
|
208
210
|
'%file_extension%',
|
@@ -235,7 +237,7 @@ end
|
|
235
237
|
|
236
238
|
# Extract compressed files +files_list+ in a ZIP archive +zipfile_name+ to +dest_path+
|
237
239
|
#
|
238
|
-
# +files_list+ is a Hash of key-value pairs. Where key is a
|
240
|
+
# +files_list+ is a Hash of key-value pairs. Where key is a possible archive filename based on current project configuration
|
239
241
|
# and value is the expanded filename
|
240
242
|
#
|
241
243
|
def unzip_file_with_translations(zipfile_name, dest_path, files_list)
|
@@ -246,7 +248,7 @@ def unzip_file_with_translations(zipfile_name, dest_path, files_list)
|
|
246
248
|
unmatched_files = []
|
247
249
|
|
248
250
|
Zip::File.open(zipfile_name) do |zipfile|
|
249
|
-
zipfile.select{ |zip_entry| zip_entry.file? }.each do |f|
|
251
|
+
zipfile.select { |zip_entry| zip_entry.file? }.each do |f|
|
250
252
|
# `f' - relative path in archive
|
251
253
|
file = files_list[f.name]
|
252
254
|
if file
|
@@ -316,6 +318,13 @@ def display_tree(files_tree, level = -2, branches = [])
|
|
316
318
|
end
|
317
319
|
end
|
318
320
|
|
321
|
+
class String
|
322
|
+
def strip_heredoc
|
323
|
+
indent = scan(/^[ \t]*(?=\S)/).min.size || 0
|
324
|
+
gsub(/^[ \t]{#{indent}}/, '')
|
325
|
+
end
|
326
|
+
end
|
327
|
+
|
319
328
|
###
|
320
329
|
include GLI::App
|
321
330
|
|
@@ -329,7 +338,7 @@ sort_help :manually # help commands are ordered in the order declared
|
|
329
338
|
wrap_help_text :to_terminal
|
330
339
|
|
331
340
|
desc I18n.t('app.switches.verbose.desc')
|
332
|
-
switch [:v, :verbose], :
|
341
|
+
switch [:v, :verbose], negatable: false
|
333
342
|
|
334
343
|
desc I18n.t('app.flags.config.desc')
|
335
344
|
default_value File.join(Dir.pwd, 'crowdin.yaml')
|
@@ -389,7 +398,7 @@ command :upload do |c|
|
|
389
398
|
local_files << local_file
|
390
399
|
else
|
391
400
|
Find.find(@base_path) do |source_path|
|
392
|
-
dest = source_path.sub(/\A#{@base_path}/, '') # relative path in Crowdin
|
401
|
+
dest = source_path.sub(/\A#{Regexp.escape(@base_path)}/, '') # relative path in Crowdin
|
393
402
|
|
394
403
|
if File.directory?(source_path)
|
395
404
|
if ignores.any? { |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
|
@@ -418,11 +427,11 @@ command :upload do |c|
|
|
418
427
|
end # @config['files']
|
419
428
|
|
420
429
|
if dest_files.empty?
|
421
|
-
exit_now!
|
422
|
-
No source files to upload.
|
423
|
-
Check your configuration file to ensure that they contain valid directives.
|
424
|
-
See http://crowdin.com/page/cli-tool#configuration-file for more details.
|
425
|
-
EOS
|
430
|
+
exit_now! <<-EOS.strip_heredoc
|
431
|
+
No source files to upload.
|
432
|
+
Check your configuration file to ensure that they contain valid directives.
|
433
|
+
See http://crowdin.com/page/cli-tool#configuration-file for more details.
|
434
|
+
EOS
|
426
435
|
end
|
427
436
|
|
428
437
|
common_dir = @preserve_hierarchy ? '' : find_common_directory_path(dest_files)
|
@@ -435,7 +444,7 @@ EOS
|
|
435
444
|
#
|
436
445
|
create_dirs = local_project_tree[:dirs] - remote_project_tree[:dirs]
|
437
446
|
create_dirs.each do |dir|
|
438
|
-
puts "
|
447
|
+
puts "Creating directory `#{dir}`"
|
439
448
|
@crowdin.add_directory(dir)
|
440
449
|
end
|
441
450
|
|
@@ -524,7 +533,7 @@ EOS
|
|
524
533
|
if project_languages.include?(language)
|
525
534
|
project_languages = [] << language
|
526
535
|
else
|
527
|
-
exit_now!("language '#{language}' doesn't exist in
|
536
|
+
exit_now!("language '#{language}' doesn't exist in the project")
|
528
537
|
end
|
529
538
|
end
|
530
539
|
|
@@ -557,7 +566,8 @@ EOS
|
|
557
566
|
end
|
558
567
|
|
559
568
|
if File.exists?(File.join(@base_path, file['source']))
|
560
|
-
dest = file['
|
569
|
+
dest = file['dest'] || file['source']
|
570
|
+
dest.sub!(/\A#{Regexp.escape(@base_path)}/, '')
|
561
571
|
dest_files << dest
|
562
572
|
|
563
573
|
file_translation_languages.each do |lang|
|
@@ -566,7 +576,7 @@ EOS
|
|
566
576
|
end
|
567
577
|
else
|
568
578
|
Find.find(@base_path) do |source_path|
|
569
|
-
dest = source_path.sub(/\A#{@base_path}/, '') # relative path in Crowdin
|
579
|
+
dest = source_path.sub(/\A#{Regexp.escape(@base_path)}/, '') # relative path in Crowdin
|
570
580
|
|
571
581
|
if File.directory?(source_path)
|
572
582
|
if ignores.any? { |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
|
@@ -593,11 +603,11 @@ EOS
|
|
593
603
|
end # @config['files']
|
594
604
|
|
595
605
|
if dest_files.empty?
|
596
|
-
exit_now!
|
597
|
-
No translation files to upload.
|
598
|
-
Check your configuration file to ensure that they contain valid directives.
|
599
|
-
See
|
600
|
-
EOS
|
606
|
+
exit_now! <<-EOS.strip_heredoc
|
607
|
+
No translation files to upload.
|
608
|
+
Check your configuration file to ensure that they contain valid directives.
|
609
|
+
See https://crowdin.com/page/cli-tool#configuration-file for more details.
|
610
|
+
EOS
|
601
611
|
end
|
602
612
|
|
603
613
|
common_dir = @preserve_hierarchy ? '' : find_common_directory_path(dest_files)
|
@@ -608,23 +618,23 @@ EOS
|
|
608
618
|
|
609
619
|
if remote_project_tree[:files].include?(file[:dest])
|
610
620
|
if File.exist?(file[:source])
|
611
|
-
print "Uploading translation file `#{file[:source].sub(/\A#{@base_path}/, '')}'"
|
621
|
+
print "Uploading translation file `#{file[:source].sub(/\A#{Regexp.escape(@base_path)}/, '')}'"
|
612
622
|
|
613
623
|
resp = @crowdin.upload_translation([] << file, language, params)
|
614
624
|
case resp['files'].first[1]
|
615
625
|
when 'skipped'
|
616
|
-
puts "\rUploading translation file `#{file[:source].sub(/\A#{@base_path}/, '')}' - Skipped"
|
626
|
+
puts "\rUploading translation file `#{file[:source].sub(/\A#{Regexp.escape(@base_path)}/, '')}' - Skipped"
|
617
627
|
when 'uploaded'
|
618
|
-
puts "\rUploading translation file `#{file[:source].sub(/\A#{@base_path}/, '')}' - OK"
|
628
|
+
puts "\rUploading translation file `#{file[:source].sub(/\A#{Regexp.escape(@base_path)}/, '')}' - OK"
|
619
629
|
when 'not_allowed'
|
620
|
-
puts "\rUploading translation file `#{file[:source].sub(/\A#{@base_path}/, '')}' - is not possible"
|
630
|
+
puts "\rUploading translation file `#{file[:source].sub(/\A#{Regexp.escape(@base_path)}/, '')}' - is not possible"
|
621
631
|
end
|
622
632
|
else
|
623
633
|
puts "Warning: Local file `#{file[:source]}' does not exist"
|
624
634
|
end
|
625
635
|
else
|
626
636
|
# if source file does not exist, don't upload translations
|
627
|
-
puts "Warning: Skip `#{file[:source].sub(/\A#{@base_path}/, '')}'"
|
637
|
+
puts "Warning: Skip `#{file[:source].sub(/\A#{Regexp.escape(@base_path)}/, '')}'. Translation can not be uploaded for a non-existent source file `#{file[:dest]}'. Please upload sources first."
|
628
638
|
end
|
629
639
|
end
|
630
640
|
end
|
@@ -641,7 +651,7 @@ command :download do |c|
|
|
641
651
|
c.desc I18n.t('app.commands.download.flags.language.desc')
|
642
652
|
c.long_desc I18n.t('app.commands.download.flags.language.long_desc')
|
643
653
|
c.arg_name 'language_code'
|
644
|
-
c.flag [:l, :language], :
|
654
|
+
c.flag [:l, :language], default_value: 'all'
|
645
655
|
|
646
656
|
c.action do |global_options ,options, args|
|
647
657
|
language = options[:language]
|
@@ -669,7 +679,7 @@ command :download do |c|
|
|
669
679
|
end
|
670
680
|
|
671
681
|
# use export API method before to download the most recent translations
|
672
|
-
print '
|
682
|
+
print 'Building ZIP archive with the latest translations '
|
673
683
|
export_translations = @crowdin.export_translations
|
674
684
|
if export_translations['success']
|
675
685
|
if export_translations['success']['status'] == 'built'
|
@@ -704,7 +714,7 @@ command :download do |c|
|
|
704
714
|
end
|
705
715
|
|
706
716
|
if File.exists?(File.join(@base_path, file['source']))
|
707
|
-
dest = file['source'].sub(/\A#{@base_path}/, '')
|
717
|
+
dest = file['source'].sub(/\A#{Regexp.escape(@base_path)}/, '')
|
708
718
|
|
709
719
|
file_translation_languages.each do |lang|
|
710
720
|
zipped_file = export_pattern_to_path(dest, file['translation'], lang)
|
@@ -715,7 +725,7 @@ command :download do |c|
|
|
715
725
|
|
716
726
|
else
|
717
727
|
Find.find(@base_path) do |source_path|
|
718
|
-
dest = source_path.sub(/\A#{@base_path}/, '') # relative path in Crowdin
|
728
|
+
dest = source_path.sub(/\A#{Regexp.escape(@base_path)}/, '') # relative path in Crowdin
|
719
729
|
|
720
730
|
if File.directory?(source_path)
|
721
731
|
if ignores.any? { |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
|
@@ -762,7 +772,7 @@ command :list do |ls_cmd|
|
|
762
772
|
ls_cmd.desc I18n.t('app.commands.list.commands.project.desc')
|
763
773
|
ls_cmd.command :project do |proj_cmd|
|
764
774
|
proj_cmd.desc I18n.t('app.commands.list.switches.tree.desc')
|
765
|
-
proj_cmd.switch ['tree'], :
|
775
|
+
proj_cmd.switch ['tree'], negatable: false
|
766
776
|
|
767
777
|
proj_cmd.action do |global_options, options, args|
|
768
778
|
project_info = @crowdin.project_info
|
@@ -780,7 +790,7 @@ command :list do |ls_cmd|
|
|
780
790
|
ls_cmd.desc I18n.t('app.commands.list.commands.sources.desc')
|
781
791
|
ls_cmd.command :sources do |src_cmd|
|
782
792
|
src_cmd.desc I18n.t('app.commands.list.switches.tree.desc')
|
783
|
-
src_cmd.switch ['tree'], :
|
793
|
+
src_cmd.switch ['tree'], negatable: false
|
784
794
|
|
785
795
|
src_cmd.action do |global_options, options, args|
|
786
796
|
local_files = []
|
@@ -806,7 +816,7 @@ command :list do |ls_cmd|
|
|
806
816
|
local_files << local_file
|
807
817
|
else
|
808
818
|
Find.find(@base_path) do |source_path|
|
809
|
-
dest = source_path.sub(/\A#{@base_path}/, '') # relative path in Crowdin
|
819
|
+
dest = source_path.sub(/\A#{Regexp.escape(@base_path)}/, '') # relative path in Crowdin
|
810
820
|
|
811
821
|
if File.directory?(source_path)
|
812
822
|
if ignores.any? { |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
|
@@ -850,7 +860,7 @@ command :list do |ls_cmd|
|
|
850
860
|
ls_cmd.desc I18n.t('app.commands.list.commands.translations.desc')
|
851
861
|
ls_cmd.command :translations do |trans_cmd|
|
852
862
|
trans_cmd.desc I18n.t('app.commands.list.switches.tree.desc')
|
853
|
-
trans_cmd.switch ['tree'], :
|
863
|
+
trans_cmd.switch ['tree'], negatable: false
|
854
864
|
|
855
865
|
trans_cmd.action do |global_options, options, args|
|
856
866
|
project_info = @crowdin.project_info
|
@@ -867,7 +877,7 @@ command :list do |ls_cmd|
|
|
867
877
|
ignores = file['ignore'] || []
|
868
878
|
|
869
879
|
if File.exists?(File.join(@base_path, file['source']))
|
870
|
-
dest = file['source'].sub(/\A#{@base_path}/, '')
|
880
|
+
dest = file['source'].sub(/\A#{Regexp.escape(@base_path)}/, '')
|
871
881
|
|
872
882
|
translation_languages.each do |lang|
|
873
883
|
local_file = export_pattern_to_path(dest, file['translation'], lang, languages_mapping)
|
@@ -876,7 +886,7 @@ command :list do |ls_cmd|
|
|
876
886
|
|
877
887
|
else
|
878
888
|
Find.find(@base_path) do |source_path|
|
879
|
-
dest = source_path.sub(/\A#{@base_path}/, '') # relative path in Crowdin
|
889
|
+
dest = source_path.sub(/\A#{Regexp.escape(@base_path)}/, '') # relative path in Crowdin
|
880
890
|
|
881
891
|
if File.directory?(source_path)
|
882
892
|
if ignores.any? { |pattern| File.fnmatch?(pattern, dest, File::FNM_PATHNAME) }
|
@@ -935,70 +945,107 @@ pre do |globals ,command, options, args|
|
|
935
945
|
]
|
936
946
|
|
937
947
|
unless File.exists?(globals[:config])
|
938
|
-
exit_now!
|
939
|
-
Can't find configuration file (default `crowdin.yaml').
|
940
|
-
Type `crowdin-cli help` to know how to specify custom configuration file
|
948
|
+
exit_now! <<-EOS.strip_heredoc
|
949
|
+
Can't find configuration file (default `crowdin.yaml').
|
950
|
+
Type `crowdin-cli help` to know how to specify custom configuration file
|
941
951
|
|
942
|
-
See http://crowdin.com/page/cli-tool#configuration-file for more details
|
943
|
-
EOS
|
944
|
-
|
945
|
-
|
946
|
-
|
947
|
-
|
948
|
-
|
949
|
-
|
950
|
-
|
951
|
-
|
952
|
-
|
953
|
-
|
954
|
-
|
952
|
+
See http://crowdin.com/page/cli-tool#configuration-file for more details
|
953
|
+
EOS
|
954
|
+
end
|
955
|
+
|
956
|
+
# load project-specific configuration
|
957
|
+
#
|
958
|
+
begin
|
959
|
+
# undocumented feature
|
960
|
+
# you can use ERB in your config file, e.g.
|
961
|
+
# api_key: <%= # ruby code ... %>
|
962
|
+
#
|
963
|
+
@config = YAML.load(ERB.new(File.read(globals[:config])).result) || {}
|
964
|
+
rescue Psych::SyntaxError => err
|
965
|
+
exit_now! <<-EOS.strip_heredoc
|
966
|
+
Could not parse YAML: #{err.message}
|
967
|
+
|
968
|
+
We were unable to successfully parse the crowdin.yaml file that you provided - most likely it is not well-formatted YAML.
|
969
|
+
Please check whether your crowdin.yaml is valid YAML - you can use the http://yamllint.com/ validator to do this - and make any necessary changes to fix it.
|
970
|
+
EOS
|
971
|
+
end
|
955
972
|
|
956
|
-
|
957
|
-
|
958
|
-
|
959
|
-
|
973
|
+
# try to load the API credentials from an environment variable, e.g.
|
974
|
+
#
|
975
|
+
# project_identifier_env: 'CROWDIN_PROJECT_ID'
|
976
|
+
# api_key_env: 'CROWDIN_API_KEY'
|
977
|
+
#
|
978
|
+
['api_key', 'project_identifier'].each do |key|
|
979
|
+
if @config["#{key}_env"]
|
980
|
+
unless @config[key] # project credentials have a higher priority if they are specified in the config
|
981
|
+
@config[key] = ENV[@config["#{key}_env"]]
|
960
982
|
end
|
961
983
|
end
|
984
|
+
end
|
962
985
|
|
963
|
-
|
964
|
-
|
965
|
-
|
966
|
-
|
967
|
-
|
968
|
-
|
969
|
-
EOS
|
970
|
-
end
|
986
|
+
# user credentials in the user-specific config file have a higher priority than project-specific
|
987
|
+
#
|
988
|
+
if File.exists?(globals[:identity])
|
989
|
+
identity = YAML.load(ERB.new(File.read(globals[:identity])).result) || {}
|
990
|
+
['api_key', 'project_identifier', 'base_path'].each do |key|
|
991
|
+
@config[key] = identity[key] if identity[key]
|
971
992
|
end
|
993
|
+
end
|
972
994
|
|
973
|
-
|
974
|
-
|
975
|
-
|
995
|
+
['api_key', 'project_identifier'].each do |key|
|
996
|
+
unless @config[key]
|
997
|
+
exit_now! <<-EOS.strip_heredoc
|
998
|
+
Configuration file misses required option `#{key}`
|
976
999
|
|
977
|
-
See http://crowdin.com/page/cli-tool#configuration-file for more details
|
978
|
-
EOS
|
1000
|
+
See http://crowdin.com/page/cli-tool#configuration-file for more details
|
1001
|
+
EOS
|
979
1002
|
end
|
980
1003
|
end
|
981
1004
|
|
1005
|
+
unless @config['files']
|
1006
|
+
exit_now! <<-EOS.strip_heredoc
|
1007
|
+
Configuration file misses required section `files`
|
1008
|
+
|
1009
|
+
See https://crowdin.com/page/cli-tool#configuration-file for more details
|
1010
|
+
EOS
|
1011
|
+
end
|
1012
|
+
|
982
1013
|
@config['files'].each do |file|
|
1014
|
+
unless file['source']
|
1015
|
+
exit_now! <<-EOS.strip_heredoc
|
1016
|
+
Files section misses required parameter `source`
|
1017
|
+
|
1018
|
+
See https://crowdin.com/page/cli-tool#configuration-file for more details
|
1019
|
+
EOS
|
1020
|
+
end
|
1021
|
+
|
1022
|
+
unless file['translation']
|
1023
|
+
exit_now! <<-EOS.strip_heredoc
|
1024
|
+
Files section misses required parameter `translation`
|
1025
|
+
|
1026
|
+
See https://crowdin.com/page/cli-tool#configuration-file for more details
|
1027
|
+
EOS
|
1028
|
+
end
|
1029
|
+
|
983
1030
|
file['source'] = '/' + file['source'] unless file['source'].start_with?('/')
|
984
1031
|
#file['translation'] = '/' + file['translation'] unless file['translation'].start_with?('/')
|
985
1032
|
|
986
1033
|
if file['source'].include?('**')
|
987
1034
|
if file['source'].scan('**').size > 1
|
988
|
-
exit_now!
|
989
|
-
Source pattern `#{file['source']}` is not valid. The mask `**` can be used only once in the source pattern.
|
990
|
-
EOS
|
1035
|
+
exit_now! <<-EOS.strip_heredoc
|
1036
|
+
Source pattern `#{file['source']}` is not valid. The mask `**` can be used only once in the source pattern.
|
1037
|
+
EOS
|
991
1038
|
elsif file['source'].scan('**').size == 1 and !file['source'].match(/\/\*\*\//)
|
992
|
-
exit_now!
|
993
|
-
Source pattern `#{file['source']}` is not valid. The mask `**` must be surrounded by
|
994
|
-
EOS
|
1039
|
+
exit_now! <<-EOS.strip_heredoc
|
1040
|
+
Source pattern `#{file['source']}` is not valid. The mask `**` must be surrounded by slashes `/` in the source pattern.
|
1041
|
+
EOS
|
995
1042
|
end
|
996
1043
|
else
|
997
1044
|
if file['translation'].include?('**')
|
998
|
-
exit_now!
|
999
|
-
Translation pattern `#{file['translation']}` is not valid. The mask `**` can't be used.
|
1000
|
-
When using `**` in 'translation' pattern it will always contain sub-path from 'source' for certain file.
|
1001
|
-
EOS
|
1045
|
+
exit_now! <<-EOS.strip_heredoc
|
1046
|
+
Translation pattern `#{file['translation']}` is not valid. The mask `**` can't be used.
|
1047
|
+
When using `**` in 'translation' pattern it will always contain sub-path from 'source' for certain file.
|
1048
|
+
EOS
|
1002
1049
|
end
|
1003
1050
|
end
|
1004
1051
|
|
@@ -1008,9 +1055,9 @@ EOS
|
|
1008
1055
|
@base_path = @config['base_path']
|
1009
1056
|
else
|
1010
1057
|
@base_path = Dir.pwd
|
1011
|
-
puts
|
1012
|
-
Warning: Configuration file misses parameter `base_path` that defines your project root directory. Using `#{@base_path}` as a root directory.
|
1013
|
-
EOS
|
1058
|
+
puts <<-EOS.strip_heredoc
|
1059
|
+
Warning: Configuration file misses parameter `base_path` that defines your project root directory. Using `#{@base_path}` as a root directory.
|
1060
|
+
EOS
|
1014
1061
|
end
|
1015
1062
|
|
1016
1063
|
@preserve_hierarchy = false
|
@@ -1021,9 +1068,9 @@ EOS
|
|
1021
1068
|
when false
|
1022
1069
|
false
|
1023
1070
|
else
|
1024
|
-
exit_now!
|
1025
|
-
Parameter `preserve_hierarchy` allows values of true or false.
|
1026
|
-
EOS
|
1071
|
+
exit_now! <<-EOS.strip_heredoc
|
1072
|
+
Parameter `preserve_hierarchy` allows values of true or false.
|
1073
|
+
EOS
|
1027
1074
|
end
|
1028
1075
|
end
|
1029
1076
|
|
@@ -1053,7 +1100,7 @@ post do |globals, command, options, args|
|
|
1053
1100
|
# Post logic here
|
1054
1101
|
# Use skips_post before a command to skip this
|
1055
1102
|
# block on that command only
|
1056
|
-
#puts "Executed #{command.name}" if globals[:verbose]
|
1103
|
+
# puts "Executed #{command.name}" if globals[:verbose]
|
1057
1104
|
end
|
1058
1105
|
|
1059
1106
|
on_error do |exception|
|
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.4.
|
4
|
+
version: 0.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crowdin
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -156,7 +156,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
156
156
|
version: '0'
|
157
157
|
requirements: []
|
158
158
|
rubyforge_project:
|
159
|
-
rubygems_version: 2.
|
159
|
+
rubygems_version: 2.4.5
|
160
160
|
signing_key:
|
161
161
|
specification_version: 4
|
162
162
|
summary: Crowdin CLI.
|