web_translate_it 2.4.10 → 2.5.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eb3fcef09897665d610fe38915e9a5f68858357f6e11839be6f34c10286dfb0f
4
- data.tar.gz: 70cad073ebdac68cceb0d54688a0168f9794d9ca9adeda8520a5cecce68d021d
3
+ metadata.gz: bb952e216ebe7b504b0c40dfcc1659795e527b0822c4d952cdba9d251b0f32b5
4
+ data.tar.gz: 685717f0eb53fe6e5f42c35896cedcfeeb39555e8e7eaf0a4fad7caa3edf237a
5
5
  SHA512:
6
- metadata.gz: 755ac1081486d0937458aa143093f9ba017d5c012bc972cf46d3294110c82240ded1aba0941a5b1fce71285808b56e466c4ef158978e57864011a46eea2209d5
7
- data.tar.gz: ff08d126ad22c2b3129301e03dd0ecda77a36b6ce54fce572ca15c09b45aac11768c15cab8038377f0c2bc2b332cac8ab965c4d65e6b37fe3692b5d6f9ea10ea
6
+ metadata.gz: 49894fbc42db771158b68e233bbfc1e197d4eb1299f47a25270d4fdd3dbccd846e2018e86b291109bd4195bcdab31188fc518d8bbbf3f65cbd33deb2d0bd6a18
7
+ data.tar.gz: 1f78011a382d2d4e8ffc9e21135c6e2899420d04403fa3481ce1ced2a9194610285abcec8b78ae8214519cde9106048f2fe1c4ea1e6b1a257e7f4739fe3e1886
data/bin/wti CHANGED
@@ -40,7 +40,7 @@ command_options = case command
40
40
  wti pull [filename] - Pull target language file(s)
41
41
  [options] are:
42
42
  EOS
43
- opt :locale, "ISO code of locale(s) to pull", type: :string
43
+ opt :locale, "ISO code of locale(s) to pull, space-separated", type: :string
44
44
  opt :all, "Pull all files"
45
45
  opt :force, "Force pull (bypass conditional requests to WTI)"
46
46
  opt :config, "Path to a configuration file", short: "-c", default: ".wti"
@@ -52,7 +52,7 @@ EOS
52
52
  wti push [filename] - Push master language file(s)
53
53
  [options] are:
54
54
  EOS
55
- opt :locale, "ISO code of locale(s) to push", type: :string
55
+ opt :locale, "ISO code of locale(s) to push, space-separated", type: :string
56
56
  opt :target, "Upload all target files"
57
57
  opt :force, "Force push (bypass conditional requests to WTI)"
58
58
  opt :low_priority, "WTI will process this file with a low priority"
@@ -97,7 +97,7 @@ EOS
97
97
  end
98
98
  when "status"
99
99
  Optimist::options do
100
- banner "wti status - Fetch and display project statistics"
100
+ banner "wti status - Fetch and display project statistics.\nReturns 100 if untranslated segments exist in project\nReturns 101 if unproofread segments exist in project."
101
101
  opt :config, "Path to a configuration file", short: "-c", default: ".wti"
102
102
  opt :debug, "Display debug information"
103
103
  end
data/history.md CHANGED
@@ -1,3 +1,37 @@
1
+ ## Version 2.5.1 / 2021-11-15
2
+
3
+ * Ruby 3.1.0 compatible.
4
+
5
+ ## Version 2.5.0 / 2021-11-15
6
+
7
+ * Display files that are being updated on WebTranslateIt but are not ready to be downloaded by a `*`.
8
+
9
+ ``` bash
10
+ ~/Desktop/test% wti pull
11
+ # Pulling files on test 3
12
+ *cs-CZ.de.yml | 65a7fc8..65a7fc8 Skipped
13
+ en.yml | ffd8096..ffd8096 Skipped
14
+ i18nextv4.de.json | 142aca7..142aca7 Skipped
15
+ *cs-CZ.yml | 42c32a3..42c32a3 Skipped
16
+ de.yml | 9dda491..9dda491 Skipped
17
+ test.de.json | 48a9c13..48a9c13 Skipped
18
+ test.de.txt | 8f305f3..8f305f3 Skipped
19
+ test.json | 7a9478f..7a9478f Skipped
20
+ i18nextv4.json | 84d6cdf..8776cb3 OK
21
+ test.txt | 8f305f3..7a1a5db OK
22
+ ```
23
+ * Improve help on `wti status` documentation.
24
+
25
+ ## Version 2.4.12 / 2021-06-30
26
+
27
+ * Add ability to pass project API token as an ENV variable. You can run:
28
+ `export WTI_PROJECT_API_KEY=[my_api_token]`
29
+ `wti pull`
30
+
31
+ ## Version 2.4.11 / 2019-10-22
32
+
33
+ * Fix for `wti pull` without parameters.
34
+
1
35
  ## Version 2.4.10 / 2019-10-21
2
36
 
3
37
  * New command: `wti mv path/to/file.po newpath/to/file.po` to move a language file
@@ -46,7 +46,7 @@ module WebTranslateIt
46
46
  parameters.each do |parameter|
47
47
  found_files += files.find_all{ |file| File.fnmatch(parameter, file.file_path) }
48
48
  end
49
- files = found_files
49
+ files = found_files if parameters.any?
50
50
  files = files.uniq.sort{ |a,b| a.file_path <=> b.file_path }
51
51
  if files.size == 0
52
52
  puts "No files to pull."
@@ -113,7 +113,7 @@ module WebTranslateIt
113
113
  to_add = parameters.reject{ |param| added.include?(File.expand_path(param))}
114
114
  if to_add.any?
115
115
  to_add.each do |param|
116
- file = TranslationFile.new(nil, param, nil, configuration.api_key)
116
+ file = TranslationFile.new(nil, param.gsub(/ /, "\\ "), nil, configuration.api_key)
117
117
  success = file.create(http, command_options.low_priority)
118
118
  complete_success = false if !success
119
119
  end
@@ -20,12 +20,12 @@ module WebTranslateIt
20
20
  self.path = root_path
21
21
  self.logger = logger
22
22
  if File.exists?(File.expand_path(path_to_config_file, self.path))
23
- self.api_key = configuration['api_key']
23
+ self.api_key = ENV["WTI_PROJECT_API_KEY"] || configuration['api_key']
24
24
  self.before_pull = configuration['before_pull']
25
25
  self.after_pull = configuration['after_pull']
26
26
  self.before_push = configuration['before_push']
27
27
  self.after_push = configuration['after_push']
28
- project_info = YAML.load WebTranslateIt::Project.fetch_info(api_key)
28
+ project_info = YAML.safe_load WebTranslateIt::Project.fetch_info(api_key), permitted_classes: [Time]
29
29
  set_locales_to_ignore(configuration)
30
30
  set_locales_needed(configuration)
31
31
  set_files(project_info['project'])
@@ -71,7 +71,7 @@ module WebTranslateIt
71
71
  if project_file['name'].nil? or project_file['name'].strip == ''
72
72
  puts "File #{project_file['id']} not set up"
73
73
  else
74
- self.files.push TranslationFile.new(project_file['id'], project_file['name'], project_file['locale_code'], self.api_key, project_file['updated_at'], project_file['hash_file'], project_file['master_project_file_id'])
74
+ self.files.push TranslationFile.new(project_file['id'], project_file['name'], project_file['locale_code'], self.api_key, project_file['updated_at'], project_file['hash_file'], project_file['master_project_file_id'], project_file['fresh'])
75
75
  end
76
76
  end
77
77
  end
@@ -12,9 +12,9 @@ module WebTranslateIt
12
12
  require 'time'
13
13
  require 'fileutils'
14
14
 
15
- attr_accessor :id, :file_path, :locale, :api_key, :updated_at, :remote_checksum, :master_id
15
+ attr_accessor :id, :file_path, :locale, :api_key, :updated_at, :remote_checksum, :master_id, :fresh
16
16
 
17
- def initialize(id, file_path, locale, api_key, updated_at = nil, remote_checksum = "", master_id = nil)
17
+ def initialize(id, file_path, locale, api_key, updated_at = nil, remote_checksum = "", master_id = nil, fresh = nil)
18
18
  self.id = id
19
19
  self.file_path = file_path
20
20
  self.locale = locale
@@ -22,6 +22,7 @@ module WebTranslateIt
22
22
  self.updated_at = updated_at
23
23
  self.remote_checksum = remote_checksum
24
24
  self.master_id = master_id
25
+ self.fresh = fresh
25
26
  end
26
27
 
27
28
  # Fetch a language file.
@@ -40,7 +41,11 @@ module WebTranslateIt
40
41
  success = true
41
42
  tries ||= 3
42
43
  display = []
43
- display.push(self.file_path)
44
+ if self.fresh
45
+ display.push(self.file_path)
46
+ else
47
+ display.push("*#{self.file_path}")
48
+ end
44
49
  display.push "#{StringUtil.checksumify(self.local_checksum.to_s)}..#{StringUtil.checksumify(self.remote_checksum.to_s)}"
45
50
  if !File.exist?(self.file_path) or force or self.remote_checksum != self.local_checksum
46
51
  begin
@@ -1,6 +1,10 @@
1
1
  class ArrayUtil
2
2
  def self.to_columns(arr)
3
- " #{StringUtil.backward_truncate(arr[0])} | #{arr[1]} #{arr[2]}\n"
3
+ if arr[0][0] == "*"
4
+ "*#{StringUtil.backward_truncate(arr[0][1..-1])} | #{arr[1]} #{arr[2]}\n"
5
+ else
6
+ " #{StringUtil.backward_truncate(arr[0])} | #{arr[1]} #{arr[2]}\n"
7
+ end
4
8
  end
5
9
 
6
10
  def self.chunk(arr, pieces=2)
data/readme.md CHANGED
@@ -276,4 +276,4 @@ fr: 100% translated, 100% completed.
276
276
 
277
277
  # License
278
278
 
279
- Copyright (c) 2009-2019 WebTranslateIt Software S.L, released under the MIT License.
279
+ Copyright (c) 2009-2021 WebTranslateIt Software S.L, released under the MIT License.
@@ -1,23 +1,23 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe WebTranslateIt::String do
4
-
5
- let(:api_key) { "19875cfdd4f169b33e0ffab32cfb0bbb9e33d653" }
6
-
4
+
5
+ let(:api_key) { "proj_pvt_glzDR250FLXlMgJPZfEyHQ" }
6
+
7
7
  describe "#initialize" do
8
8
  it "should assign api_key and many parameters" do
9
9
  string = WebTranslateIt::String.new({ "id" => 1234, "key" => "bacon"})
10
10
  string.id.should == 1234
11
11
  string.key.should == "bacon"
12
12
  end
13
-
13
+
14
14
  it "should assign parameters using symbols" do
15
15
  string = WebTranslateIt::String.new({ :id => 1234, :key => "bacon"})
16
16
  string.id.should == 1234
17
17
  string.key.should == "bacon"
18
18
  end
19
19
  end
20
-
20
+
21
21
  describe "#save" do
22
22
  it "should create a new String" do
23
23
  WebTranslateIt::Connection.new(api_key) do
@@ -31,7 +31,7 @@ describe WebTranslateIt::String do
31
31
  string.delete
32
32
  end
33
33
  end
34
-
34
+
35
35
  it "should update an existing String" do
36
36
  WebTranslateIt::Connection.new(api_key) do
37
37
  string = WebTranslateIt::String.new({ "key" => "bacony" })
@@ -43,11 +43,11 @@ describe WebTranslateIt::String do
43
43
  string.delete
44
44
  end
45
45
  end
46
-
46
+
47
47
  it "should create a new String with Translation" do
48
48
  translation1 = WebTranslateIt::Translation.new({ "locale" => "en", "text" => "Hello" })
49
49
  translation2 = WebTranslateIt::Translation.new({ "locale" => "fr", "text" => "Bonjour" })
50
-
50
+
51
51
  string = WebTranslateIt::String.new({ "key" => "bacon", "translations" => [translation1, translation2] })
52
52
  WebTranslateIt::Connection.new(api_key) do
53
53
  string.save
@@ -60,20 +60,20 @@ describe WebTranslateIt::String do
60
60
  string.delete
61
61
  end
62
62
  end
63
-
63
+
64
64
  it "should update a String and save its Translation" do
65
65
  translation1 = WebTranslateIt::Translation.new({ "locale" => "en", "text" => "Hello" })
66
66
  translation2 = WebTranslateIt::Translation.new({ "locale" => "fr", "text" => "Bonjour" })
67
-
67
+
68
68
  string = WebTranslateIt::String.new({ "key" => "bacon" })
69
69
  WebTranslateIt::Connection.new(api_key) do
70
70
  string.save
71
71
  string_fetched = WebTranslateIt::String.find(string.id)
72
72
  string_fetched.translation_for("fr").should be_nil
73
-
73
+
74
74
  string_fetched.translations = [translation1, translation2]
75
75
  string_fetched.save
76
-
76
+
77
77
  string_fetched = WebTranslateIt::String.find(string.id)
78
78
  string_fetched.translation_for("en").should_not be_nil
79
79
  string_fetched.translation_for("en").text.should == "Hello"
@@ -83,7 +83,7 @@ describe WebTranslateIt::String do
83
83
  end
84
84
  end
85
85
  end
86
-
86
+
87
87
  describe "#delete" do
88
88
  it "should delete a String" do
89
89
  string = WebTranslateIt::String.new({ "key" => "bacon" })
@@ -91,53 +91,48 @@ describe WebTranslateIt::String do
91
91
  string.save
92
92
  string_fetched = WebTranslateIt::String.find(string.id)
93
93
  string_fetched.should_not be_nil
94
-
94
+
95
95
  string_fetched.delete
96
96
  WebTranslateIt::String.find(string.id).should be_nil
97
97
  end
98
98
  end
99
99
  end
100
-
100
+
101
101
  describe "#find_all" do
102
102
  it "should find many strings" do
103
103
  WebTranslateIt::Connection.new(api_key) do
104
- string1 = WebTranslateIt::String.new({ "key" => "bacon" })
104
+ string1 = WebTranslateIt::String.new({ "key" => "one two three" })
105
105
  string1.save
106
- string2 = WebTranslateIt::String.new({ "key" => "tart" })
106
+ string2 = WebTranslateIt::String.new({ "key" => "four five six" })
107
107
  string2.save
108
- string3 = WebTranslateIt::String.new({ "key" => "bacon tart" })
108
+ string3 = WebTranslateIt::String.new({ "key" => "six seven eight" })
109
109
  string3.save
110
-
111
- strings = WebTranslateIt::String.find_all({ "key" => "bacon" })
112
- strings.count.should == 2
113
- strings[0].key.should == "bacon"
114
- strings[1].key.should == "bacon tart"
115
-
116
- strings = WebTranslateIt::String.find_all({ :key => "bacon" })
110
+
111
+ strings = WebTranslateIt::String.find_all({ "key" => "six" })
117
112
  strings.count.should == 2
118
- strings[0].key.should == "bacon"
119
- strings[1].key.should == "bacon tart"
113
+ strings[0].key.should == "four five six"
114
+ strings[1].key.should == "six seven eight"
120
115
 
121
- strings = WebTranslateIt::String.find_all({ "key" => "tart" })
116
+ strings = WebTranslateIt::String.find_all({ :key => "six" })
122
117
  strings.count.should == 2
123
- strings[0].key.should == "tart"
124
- strings[1].key.should == "bacon tart"
125
-
126
- strings = WebTranslateIt::String.find_all({ "key" => "bacon tart" })
118
+ strings[0].key.should == "four five six"
119
+ strings[1].key.should == "six seven eight"
120
+
121
+ strings = WebTranslateIt::String.find_all({ "key" => "eight" })
122
+ strings.count.should == 1
123
+ strings[0].key.should == "six seven eight"
124
+
125
+ strings = WebTranslateIt::String.find_all({ "key" => "three" })
127
126
  strings.count.should == 1
128
- strings[0].key.should == "bacon tart"
129
-
130
- string1.delete
131
- string2.delete
132
- string3.delete
127
+ strings[0].key.should == "one two three"
133
128
  end
134
129
  end
135
130
  end
136
-
131
+
137
132
  describe "#translation_for" do
138
133
  it "should fetch translations" do
139
134
  translation = WebTranslateIt::Translation.new({ "locale" => "en", "text" => "Hello" })
140
- string = WebTranslateIt::String.new({ "key" => "bacon", "translations" => [translation] })
135
+ string = WebTranslateIt::String.new({ "key" => "greetings", "translations" => [translation] })
141
136
  WebTranslateIt::Connection.new(api_key) do
142
137
  string.save
143
138
  string_fetched = WebTranslateIt::String.find(string.id)
@@ -147,9 +142,9 @@ describe WebTranslateIt::String do
147
142
  string.delete
148
143
  end
149
144
  end
150
-
145
+
151
146
  it "should not return a stale object" do
152
- string = WebTranslateIt::String.new({ :key => "bacon" })
147
+ string = WebTranslateIt::String.new({ :key => "greetings 2" })
153
148
  translation = WebTranslateIt::Translation.new({ :locale => "es", :text => "text", :string_id => string.id })
154
149
  string.translations << translation
155
150
  string.translation_for('fr').should be_nil
@@ -1,9 +1,9 @@
1
1
  require 'spec_helper'
2
2
 
3
3
  describe WebTranslateIt::Term do
4
-
5
- let(:api_key) { "19875cfdd4f169b33e0ffab32cfb0bbb9e33d653" }
6
-
4
+
5
+ let(:api_key) { "proj_pvt_glzDR250FLXlMgJPZfEyHQ" }
6
+
7
7
  describe "#initialize" do
8
8
  it "should assign api_key and many parameters" do
9
9
  term = WebTranslateIt::Term.new({ "id" => 1234, "text" => "bacon"})
@@ -17,7 +17,7 @@ describe WebTranslateIt::Term do
17
17
  term.text.should == "bacon"
18
18
  end
19
19
  end
20
-
20
+
21
21
  describe "#save" do
22
22
  it "should create a new Term" do
23
23
  WebTranslateIt::Connection.new(api_key) do
@@ -31,10 +31,10 @@ describe WebTranslateIt::Term do
31
31
  term.delete
32
32
  end
33
33
  end
34
-
34
+
35
35
  it "should update an existing Term" do
36
36
  WebTranslateIt::Connection.new(api_key) do
37
- term = WebTranslateIt::Term.new({ "text" => "Term", "description" => "A description" })
37
+ term = WebTranslateIt::Term.new({ "text" => "Term 2", "description" => "A description" })
38
38
  term.save
39
39
  term.text = "A Term"
40
40
  term.save
@@ -43,11 +43,11 @@ describe WebTranslateIt::Term do
43
43
  term.delete
44
44
  end
45
45
  end
46
-
46
+
47
47
  it "should create a new Term with a TermTranslation" do
48
48
  translation1 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Bonjour" })
49
49
  translation2 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Salut" })
50
-
50
+
51
51
  term = WebTranslateIt::Term.new({ "text" => "Hello", "translations" => [translation1, translation2] })
52
52
  WebTranslateIt::Connection.new(api_key) do
53
53
  term.save
@@ -59,20 +59,20 @@ describe WebTranslateIt::Term do
59
59
  term.delete
60
60
  end
61
61
  end
62
-
62
+
63
63
  it "should update a Term and save its Translation" do
64
64
  translation1 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Bonjour" })
65
65
  translation2 = WebTranslateIt::TermTranslation.new({ "locale" => "fr", "text" => "Salut" })
66
-
66
+
67
67
  term = WebTranslateIt::Term.new({ "text" => "Hi!" })
68
68
  WebTranslateIt::Connection.new(api_key) do
69
69
  term.save
70
70
  term_fetched = WebTranslateIt::Term.find(term.id)
71
71
  term_fetched.translation_for("fr").should be_nil
72
-
72
+
73
73
  term_fetched.translations = [translation1, translation2]
74
74
  term_fetched.save
75
-
75
+
76
76
  term_fetched = WebTranslateIt::Term.find(term.id)
77
77
  term_fetched.translation_for("fr").should_not be_nil
78
78
  term_fetched.translation_for("fr")[0].text.should == "Bonjour"
@@ -81,7 +81,7 @@ describe WebTranslateIt::Term do
81
81
  end
82
82
  end
83
83
  end
84
-
84
+
85
85
  describe "#delete" do
86
86
  it "should delete a Term" do
87
87
  term = WebTranslateIt::Term.new({ "text" => "bacon" })
@@ -89,27 +89,27 @@ describe WebTranslateIt::Term do
89
89
  term.save
90
90
  term_fetched = WebTranslateIt::Term.find(term.id)
91
91
  term_fetched.should_not be_nil
92
-
92
+
93
93
  term_fetched.delete
94
94
  term_fetched = WebTranslateIt::Term.find(term.id)
95
95
  term_fetched.should be_nil
96
96
  end
97
97
  end
98
98
  end
99
-
99
+
100
100
  describe "#find_all" do
101
101
  it "should fetch many terms" do
102
102
  WebTranslateIt::Connection.new(api_key) do
103
- term1 = WebTranslateIt::Term.new({ "text" => "bacon" })
103
+ term1 = WebTranslateIt::Term.new({ "text" => "greeting 1" })
104
104
  term1.save
105
- term2 = WebTranslateIt::Term.new({ "text" => "tart" })
105
+ term2 = WebTranslateIt::Term.new({ "text" => "greeting 2" })
106
106
  term2.save
107
- term3 = WebTranslateIt::Term.new({ "text" => "bacon tart" })
107
+ term3 = WebTranslateIt::Term.new({ "text" => "greeting 3" })
108
108
  term3.save
109
-
109
+
110
110
  terms = WebTranslateIt::Term.find_all
111
111
  terms.count.should == 3
112
-
112
+
113
113
  term1.delete
114
114
  term2.delete
115
115
  term3.delete
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: web_translate_it
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.4.10
4
+ version: 2.5.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edouard Briere
8
- autorequire:
8
+ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-10-21 00:00:00.000000000 Z
11
+ date: 2022-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multipart-post
@@ -124,7 +124,7 @@ homepage: https://webtranslateit.com
124
124
  licenses:
125
125
  - MIT
126
126
  metadata: {}
127
- post_install_message:
127
+ post_install_message:
128
128
  rdoc_options:
129
129
  - "--main"
130
130
  - readme.md
@@ -141,9 +141,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
141
141
  - !ruby/object:Gem::Version
142
142
  version: '0'
143
143
  requirements: []
144
- rubyforge_project:
145
- rubygems_version: 2.7.7
146
- signing_key:
144
+ rubygems_version: 3.0.9
145
+ signing_key:
147
146
  specification_version: 4
148
147
  summary: A CLI to sync locale files with WebTranslateIt.com.
149
148
  test_files: