web_translate_it 1.7.2.1 → 1.7.3.0
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.
- data/bin/wti +1 -3
- data/examples/en.yml +19 -14
- data/history.md +7 -0
- data/lib/web_translate_it/command_line.rb +3 -23
- data/lib/web_translate_it/configuration.rb +1 -1
- data/lib/web_translate_it/translation_file.rb +14 -4
- data/lib/web_translate_it/util.rb +7 -0
- data/spec/web_translate_it/translation_file_spec.rb +0 -7
- data/version.yml +2 -2
- metadata +5 -5
data/bin/wti
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
require 'trollop'
|
4
4
|
require 'web_translate_it'
|
5
5
|
|
6
|
-
SUB_COMMANDS = %w(pull push add addlocale server
|
6
|
+
SUB_COMMANDS = %w(pull push add addlocale server status st init)
|
7
7
|
global_options = Trollop::options do
|
8
8
|
banner <<-EOS
|
9
9
|
wti is a command line tool to sync your local translation files
|
@@ -44,10 +44,8 @@ command_options = case command
|
|
44
44
|
opt :port, "Run server on a specific port", :default => 4000, :short => "-p"
|
45
45
|
opt :host, "Run server on a specific host", :default => "0.0.0.0", :short => "-h"
|
46
46
|
end
|
47
|
-
when "stats"
|
48
47
|
when "status"
|
49
48
|
when "st"
|
50
|
-
when "autoconf"
|
51
49
|
when "init"
|
52
50
|
else
|
53
51
|
Trollop::die "unknown subcommand #{command.inspect}"
|
data/examples/en.yml
CHANGED
@@ -1,10 +1,18 @@
|
|
1
|
-
|
1
|
+
fr:
|
2
2
|
activerecord:
|
3
3
|
errors:
|
4
|
+
models:
|
5
|
+
invitation:
|
6
|
+
attributes:
|
7
|
+
email:
|
8
|
+
user_already_invited: "This user has already been invited"
|
9
|
+
user_already_member: "This user is already a member"
|
10
|
+
project_file:
|
11
|
+
attributes:
|
12
|
+
file:
|
13
|
+
file_format_not_supported: "Sorry, we currenly support only Gettext .pot/.po, .yml/.yaml and .strings"
|
4
14
|
templates:
|
5
15
|
header:
|
6
|
-
one: "1 error prohibited this {{model}} from being saved"
|
7
|
-
other: "{{count}} errors prohibited this {{model}} from being saved"
|
8
16
|
body: "there were problems with the following fields:"
|
9
17
|
messages:
|
10
18
|
accepted: "must be accepted"
|
@@ -25,14 +33,11 @@ en:
|
|
25
33
|
taken: "is already taken"
|
26
34
|
too_long: "is too long (maximum is {{count}} characters)"
|
27
35
|
too_short: "is too short (minimum is {{count}} characters)"
|
28
|
-
wrong_length: "is the wrong length (should be {{count}} characters)"
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
attributes:
|
37
|
-
file:
|
38
|
-
file_format_not_supported: "Sorry, we currenly support only Gettext .pot/.po, .yml/.yaml and .strings"
|
36
|
+
wrong_length: "is the wrong length (should be {{count}} characters)"
|
37
|
+
one: "1 error prohibited this {{model}} from being saved"
|
38
|
+
other: "{{count}} errors prohibited this {{model}} from being saved"
|
39
|
+
another_one: dskjdks
|
40
|
+
another_string: "this is another string"
|
41
|
+
hello: "Hello world!!"
|
42
|
+
new_string: hehe
|
43
|
+
test: " & & "
|
data/history.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## Version 1.7.3.0 / 2011-04-12
|
2
|
+
|
3
|
+
* New: Compare local file checksum with file checksum from WTI API to determine if file needs downloading.
|
4
|
+
We were previously using the date of last modification which can be a little bit unreliable.
|
5
|
+
* Remove `wti autoconf` and `wti stats`.
|
6
|
+
These commands were deprecated in favour of `wti init` and `wti status` (and its alias `wti st`).
|
7
|
+
|
1
8
|
## Version 1.7.2.1 / 2011-03-31
|
2
9
|
|
3
10
|
* Bug fix: `wti init` fails when configuration file doesn’t exist.
|
@@ -16,7 +16,7 @@ module WebTranslateIt
|
|
16
16
|
`#{configuration.before_pull}` if configuration.before_pull
|
17
17
|
fetch_locales_to_pull.each do |locale|
|
18
18
|
configuration.files.find_all{ |file| file.locale == locale }.each do |file|
|
19
|
-
print "Pulling #{file.file_path}
|
19
|
+
print "Pulling #{file.file_path}: "
|
20
20
|
puts file.fetch(command_options.force)
|
21
21
|
end
|
22
22
|
end
|
@@ -63,17 +63,7 @@ module WebTranslateIt
|
|
63
63
|
end
|
64
64
|
puts "Done!"
|
65
65
|
end
|
66
|
-
|
67
|
-
def autoconf
|
68
|
-
puts ""
|
69
|
-
puts "============================================"
|
70
|
-
puts " Warning: `wti autoconf` will be deprecated."
|
71
|
-
puts " Please use `wti init` instead."
|
72
|
-
puts "============================================"
|
73
|
-
puts ""
|
74
|
-
init
|
75
|
-
end
|
76
|
-
|
66
|
+
|
77
67
|
def init
|
78
68
|
puts "This command configures your project."
|
79
69
|
api_key = Util.ask("Enter your project API Key:")
|
@@ -103,17 +93,7 @@ module WebTranslateIt
|
|
103
93
|
puts "Check `wti --help` for more information."
|
104
94
|
end
|
105
95
|
end
|
106
|
-
|
107
|
-
def stats
|
108
|
-
puts ""
|
109
|
-
puts "============================================="
|
110
|
-
puts " Warning: `wti stats` will be deprecated."
|
111
|
-
puts " Please use `wti status` or `wti st` instead."
|
112
|
-
puts "============================================="
|
113
|
-
puts ""
|
114
|
-
status
|
115
|
-
end
|
116
|
-
|
96
|
+
|
117
97
|
def status
|
118
98
|
stats = YAML.load(Project.fetch_stats(configuration.api_key))
|
119
99
|
stale = false
|
@@ -49,7 +49,7 @@ module WebTranslateIt
|
|
49
49
|
if project_file['name'].nil? or project_file['name'].strip == ''
|
50
50
|
puts "File #{project_file['id']} not set up"
|
51
51
|
else
|
52
|
-
self.files.push TranslationFile.new(project_file['id'], project_file['name'], project_file['locale_code'], self.api_key, project_file['updated_at'])
|
52
|
+
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'])
|
53
53
|
end
|
54
54
|
end
|
55
55
|
end
|
@@ -12,14 +12,15 @@ module WebTranslateIt
|
|
12
12
|
require 'time'
|
13
13
|
require 'fileutils'
|
14
14
|
|
15
|
-
attr_accessor :id, :file_path, :locale, :api_key, :updated_at
|
15
|
+
attr_accessor :id, :file_path, :locale, :api_key, :updated_at, :remote_checksum
|
16
16
|
|
17
|
-
def initialize(id, file_path, locale, api_key, updated_at = nil)
|
17
|
+
def initialize(id, file_path, locale, api_key, updated_at = nil, remote_checksum = "")
|
18
18
|
self.id = id
|
19
19
|
self.file_path = file_path
|
20
20
|
self.locale = locale
|
21
21
|
self.api_key = api_key
|
22
22
|
self.updated_at = updated_at
|
23
|
+
self.remote_checksum = remote_checksum
|
23
24
|
end
|
24
25
|
|
25
26
|
# Fetch a language file.
|
@@ -35,11 +36,11 @@ module WebTranslateIt
|
|
35
36
|
# file.fetch(true) # force to re-download the file, will return the content of the file with a 200 OK
|
36
37
|
#
|
37
38
|
def fetch(force = false)
|
38
|
-
|
39
|
+
print "#{self.local_checksum.checksumify}...#{self.remote_checksum.checksumify} "
|
40
|
+
if !File.exist?(self.file_path) or force or self.remote_checksum != self.local_checksum
|
39
41
|
begin
|
40
42
|
WebTranslateIt::Util.http_connection do |http|
|
41
43
|
request = Net::HTTP::Get.new(api_url)
|
42
|
-
request.add_field('If-Modified-Since', last_modification.rfc2822) if File.exist?(self.file_path) and !force
|
43
44
|
response = http.request(request)
|
44
45
|
FileUtils.mkpath(self.file_path.split('/')[0..-2].join('/')) unless File.exist?(self.file_path) or self.file_path.split('/')[0..-2].join('/') == ""
|
45
46
|
begin
|
@@ -142,5 +143,14 @@ module WebTranslateIt
|
|
142
143
|
def api_url_for_create
|
143
144
|
"/api/projects/#{self.api_key}/files"
|
144
145
|
end
|
146
|
+
|
147
|
+
def local_checksum
|
148
|
+
require 'digest/sha1'
|
149
|
+
begin
|
150
|
+
Digest::SHA1.hexdigest(File.open(file_path) { |f| f.read })
|
151
|
+
rescue
|
152
|
+
""
|
153
|
+
end
|
154
|
+
end
|
145
155
|
end
|
146
156
|
end
|
@@ -28,13 +28,6 @@ describe WebTranslateIt::TranslationFile do
|
|
28
28
|
translation_file.fetch(true).should include "200 OK"
|
29
29
|
end
|
30
30
|
|
31
|
-
it "should prepare a HTTP request and get a 304 OK if the language file is fresh" do
|
32
|
-
file = mock(File)
|
33
|
-
file.stub(:puts => true, :close => true)
|
34
|
-
File.stub(:exist? => true, :mtime => Time.now, :new => file)
|
35
|
-
translation_file.fetch.should include "304 Not Modified"
|
36
|
-
end
|
37
|
-
|
38
31
|
it "should prepare a HTTP request and get a 200 OK if the language file is fresh using the force download parameter" do
|
39
32
|
file = mock(File)
|
40
33
|
file.stub(:puts => true, :close => true)
|
data/version.yml
CHANGED
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
|
-
hash:
|
4
|
+
hash: 107
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 7
|
9
|
-
-
|
10
|
-
-
|
11
|
-
version: 1.7.
|
9
|
+
- 3
|
10
|
+
- 0
|
11
|
+
version: 1.7.3.0
|
12
12
|
platform: ruby
|
13
13
|
authors:
|
14
14
|
- "\xC3\x89douard Bri\xC3\xA8re"
|
@@ -16,7 +16,7 @@ autorequire:
|
|
16
16
|
bindir: bin
|
17
17
|
cert_chain: []
|
18
18
|
|
19
|
-
date: 2011-
|
19
|
+
date: 2011-04-12 00:00:00 +02:00
|
20
20
|
default_executable: wti
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|