web_translate_it 1.7.3.0 → 1.7.3.1
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +93 -72
- data/bin/wti +1 -1
- data/examples/en.yml +14 -19
- data/history.md +7 -0
- data/lib/web_translate_it/command_line.rb +16 -11
- data/lib/web_translate_it/project.rb +0 -1
- data/lib/web_translate_it/translation_file.rb +7 -7
- data/lib/web_translate_it/util.rb +7 -6
- data/lib/web_translate_it/views/index.erb +2 -2
- data/readme.md +93 -72
- data/spec/web_translate_it/translation_file_spec.rb +3 -3
- data/version.yml +1 -1
- metadata +7 -7
data/README.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
Web Translate It
|
2
|
+
================
|
2
3
|
|
3
4
|
[Homepage](https://webtranslateit.com) |
|
4
|
-
[
|
5
|
+
[RDoc](http://yardoc.org/docs/AtelierConvivialite-webtranslateit) |
|
5
6
|
[Example app](http://github.com/AtelierConvivialite/rails_example_app) |
|
6
7
|
[Report a bug](http://github.com/AtelierConvivialite/webtranslateit/issues) |
|
7
8
|
[Support](http://help.webtranslateit.com)
|
@@ -16,7 +17,8 @@ This gem provides:
|
|
16
17
|
* a synchronisation server to help your translation team update your language files from a web interface,
|
17
18
|
* a rack middleware you can use within your Rails app to automatically fetch new translations from Web Translate It.
|
18
19
|
|
19
|
-
|
20
|
+
Installation
|
21
|
+
------------
|
20
22
|
|
21
23
|
These instructions are for Linux and Mac OS X system. Follow [these instructions](http://help.webtranslateit.com/kb/tips/how-to-install-wti-on-windows) if you’re using Microsoft Windows.
|
22
24
|
|
@@ -24,7 +26,8 @@ These instructions are for Linux and Mac OS X system. Follow [these instructions
|
|
24
26
|
|
25
27
|
At this point you should have the `wti` executable working.
|
26
28
|
|
27
|
-
|
29
|
+
Configuration
|
30
|
+
-------------
|
28
31
|
|
29
32
|
Now that the tool is installed, you’ll have to configure your project:
|
30
33
|
|
@@ -35,7 +38,8 @@ The tool will prompt for:
|
|
35
38
|
* your Web Translate It API key (you can find it in your project settings),
|
36
39
|
* where to save the configuration file (by default in `config/translations.yml`).
|
37
40
|
|
38
|
-
|
41
|
+
Usage
|
42
|
+
-----
|
39
43
|
|
40
44
|
Execute `wti --help` to see the usage:
|
41
45
|
|
@@ -74,11 +78,92 @@ You can get more information by appending `--help` after each command. For insta
|
|
74
78
|
--label, -b <s>: Apply a label to the changes
|
75
79
|
--help, -h: Show this message
|
76
80
|
|
77
|
-
|
81
|
+
Sample Commands
|
82
|
+
---------------
|
83
|
+
|
84
|
+
<table>
|
85
|
+
<tr>
|
86
|
+
<th>Command</th>
|
87
|
+
<th>Action</th>
|
88
|
+
</tr>
|
89
|
+
<tr>
|
90
|
+
<td>wti add path/to/master/file.po</td>
|
91
|
+
<td>Upload a new master language file</td>
|
92
|
+
</tr>
|
93
|
+
<tr>
|
94
|
+
<td>wti add file1.po file2.po file3.xml</td>
|
95
|
+
<td>Create several master language files at once, by specifying each file</td>
|
96
|
+
</tr>
|
97
|
+
<tr>
|
98
|
+
<td>wti add *.po</td>
|
99
|
+
<td>Create several master language files at once, by specifying an extension</td>
|
100
|
+
</tr>
|
101
|
+
<tr>
|
102
|
+
<td>wti push</td>
|
103
|
+
<td>Update a master language file</td>
|
104
|
+
</tr>
|
105
|
+
<tr>
|
106
|
+
<td>wti push -l fr</td>
|
107
|
+
<td>Update a target (French) language file</td>
|
108
|
+
</tr>
|
109
|
+
<tr>
|
110
|
+
<td>wti push -l "fr en da sv"</td>
|
111
|
+
<td>Update several target language files at once (French, English, Danish, Swedish)</td>
|
112
|
+
</tr>
|
113
|
+
<tr>
|
114
|
+
<td>wti push --all</td>
|
115
|
+
<td>Update all language files at once</td>
|
116
|
+
</tr>
|
117
|
+
<tr>
|
118
|
+
<td>wti pull</td>
|
119
|
+
<td>Download target language files</td>
|
120
|
+
</tr>
|
121
|
+
<tr>
|
122
|
+
<td>wti pull -l fr</td>
|
123
|
+
<td>Download a specific language file (French)</td>
|
124
|
+
</tr>
|
125
|
+
<tr>
|
126
|
+
<td>wti pull --all</td>
|
127
|
+
<td>Download all language files, including source</td>
|
128
|
+
</tr>
|
129
|
+
<tr>
|
130
|
+
<td>wti pull --force</td>
|
131
|
+
<td>Force pull (to bypass Web Translate It’s HTTP caching)</td>
|
132
|
+
</tr>
|
133
|
+
<tr>
|
134
|
+
<td>wti addlocale fr</td>
|
135
|
+
<td>Add a new locale to the project</td>
|
136
|
+
</tr>
|
137
|
+
<tr>
|
138
|
+
<td>wti addlocale fr da sv</td>
|
139
|
+
<td>Add several locales at once</td>
|
140
|
+
</tr>
|
141
|
+
<tr>
|
142
|
+
<td>wti status</td>
|
143
|
+
<td>View project statistics</td>
|
144
|
+
</tr>
|
145
|
+
</table>
|
146
|
+
|
147
|
+
Hooks
|
148
|
+
-----
|
149
|
+
|
150
|
+
It is sometimes useful to hook a command or a script before or after a push or a pull. One use-case would be to launch a build after pulling language files. You can do that by implementing hooks in your `translation.yml` file.
|
151
|
+
|
152
|
+
There are 4 hooks:
|
153
|
+
|
154
|
+
* `before_pull`
|
155
|
+
* `after_pull`
|
156
|
+
* `before_push`
|
157
|
+
* `after_push`
|
158
|
+
|
159
|
+
Check the [sample `translation.yml`](https://github.com/AtelierConvivialite/webtranslateit/blob/master/examples/translation.yml#L9..L13) file for implementation.
|
160
|
+
|
161
|
+
Web Translate It Synchronisation Console
|
162
|
+
----------------------------------------
|
78
163
|
|
79
164
|
![Web Translate It](http://s3.amazonaws.com:80/edouard.baconfile.com/web_translate_it%2Fadmin_console2.png)
|
80
165
|
|
81
|
-
|
166
|
+
`wti` contains a server you can use to run a friendly web interface to sync your translations. It allows a translation team to refresh the language files on a staging server without asking the developers to manually `wti pull`.
|
82
167
|
|
83
168
|
To get started, go to the directory of the application you want to sync and do:
|
84
169
|
|
@@ -88,77 +173,13 @@ By default, it starts an application on localhost on the port 4000. You will fin
|
|
88
173
|
|
89
174
|
Should you need to use another host or port, you can use the `-h` and `-p` options. For example: `wti server -p 1234`.
|
90
175
|
|
91
|
-
You may want to run some commands before or after syncing translations.
|
176
|
+
You may want to run some commands before or after syncing translations. You can use the hooks to do so. For instance, you could add the following in your `translation.yml` file:
|
92
177
|
|
93
178
|
before_pull: "echo 'some unix command'"
|
94
179
|
after_pull: "touch tmp/restart.txt"
|
95
180
|
|
96
181
|
`before_pull` and `after_pull` are respectively executed before and after pulling language files.
|
97
182
|
|
98
|
-
## Use Cases
|
99
|
-
|
100
|
-
Here are some example commands for the most common scenarios.
|
101
|
-
|
102
|
-
### Upload a new master language file
|
103
|
-
|
104
|
-
wti add path/to/master/file.po
|
105
|
-
|
106
|
-
Create several master language files at once:
|
107
|
-
|
108
|
-
wti add file1.po file2.po file3.xml
|
109
|
-
|
110
|
-
Or:
|
111
|
-
|
112
|
-
wti add *.po
|
113
|
-
|
114
|
-
After receiving your master language files, Web Translate It will automatically create the corresponding target files. If you have already some translations for these files, use `wti push --all` to synchronise them to Web Translate It.
|
115
|
-
|
116
|
-
### Update a master language file
|
117
|
-
|
118
|
-
wti push
|
119
|
-
|
120
|
-
### Update a target language file
|
121
|
-
|
122
|
-
Update the french language file:
|
123
|
-
|
124
|
-
wti push -l fr
|
125
|
-
|
126
|
-
Or several languages at once:
|
127
|
-
|
128
|
-
wti push -l "fr en da sv"
|
129
|
-
|
130
|
-
### Update all language files at once
|
131
|
-
|
132
|
-
wti push --all
|
133
|
-
|
134
|
-
### Download target language files
|
135
|
-
|
136
|
-
wti pull
|
137
|
-
|
138
|
-
### Download a specific language file
|
139
|
-
|
140
|
-
wti pull -l fr
|
141
|
-
|
142
|
-
### Download all language files, including source
|
143
|
-
|
144
|
-
wti pull --all
|
145
|
-
|
146
|
-
### Force pull (to bypass Web Translate It’s HTTP caching)
|
147
|
-
|
148
|
-
wti pull --force
|
149
|
-
|
150
|
-
### Add a new locale to the project
|
151
|
-
|
152
|
-
wti addlocale fr
|
153
|
-
|
154
|
-
Or add several locales at once:
|
155
|
-
|
156
|
-
wti addlocale fr da sv
|
157
|
-
|
158
|
-
### View project stats
|
159
|
-
|
160
|
-
wti status
|
161
|
-
|
162
183
|
# License
|
163
184
|
|
164
185
|
Copyright (c) 2009-2011 Atelier Convivialité, released under the MIT License.
|
data/bin/wti
CHANGED
@@ -48,7 +48,7 @@ command_options = case command
|
|
48
48
|
when "st"
|
49
49
|
when "init"
|
50
50
|
else
|
51
|
-
Trollop::die "
|
51
|
+
Trollop::die "Unknown subcommand #{command.inspect}"
|
52
52
|
end
|
53
53
|
|
54
54
|
WebTranslateIt::CommandLine.new(command, command_options, global_options, ARGV, File.expand_path("."))
|
data/examples/en.yml
CHANGED
@@ -1,18 +1,10 @@
|
|
1
|
-
|
1
|
+
en:
|
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"
|
14
4
|
templates:
|
15
5
|
header:
|
6
|
+
one: "1 error prohibited this {{model}} from being saved"
|
7
|
+
other: "{{count}} errors prohibited this {{model}} from being saved"
|
16
8
|
body: "there were problems with the following fields:"
|
17
9
|
messages:
|
18
10
|
accepted: "must be accepted"
|
@@ -33,11 +25,14 @@ fr:
|
|
33
25
|
taken: "is already taken"
|
34
26
|
too_long: "is too long (maximum is {{count}} characters)"
|
35
27
|
too_short: "is too short (minimum is {{count}} characters)"
|
36
|
-
wrong_length: "is the wrong length (should be {{count}} characters)"
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
28
|
+
wrong_length: "is the wrong length (should be {{count}} characters)"
|
29
|
+
models:
|
30
|
+
invitation:
|
31
|
+
attributes:
|
32
|
+
email:
|
33
|
+
user_already_invited: "This user has already been invited"
|
34
|
+
user_already_member: "This user is already a member"
|
35
|
+
project_file:
|
36
|
+
attributes:
|
37
|
+
file:
|
38
|
+
file_format_not_supported: "Sorry, we currenly support only Gettext .pot/.po, .yml/.yaml and .strings"
|
data/history.md
CHANGED
@@ -1,3 +1,10 @@
|
|
1
|
+
## Version 1.7.3.1 / 2011-05-06
|
2
|
+
|
3
|
+
* Fix: Broken links on `wti server`.
|
4
|
+
* Fix: Avoid crashes on blank checksums. Ticket #53
|
5
|
+
This bug could happen when the file checksum is not yet calculated by WTI server, typically by doing a wti push, then wti pull too quickly.
|
6
|
+
* Update Sinatra to 1.2.6.
|
7
|
+
|
1
8
|
## Version 1.7.3.0 / 2011-04-12
|
2
9
|
|
3
10
|
* New: Compare local file checksum with file checksum from WTI API to determine if file needs downloading.
|
@@ -14,9 +14,12 @@ module WebTranslateIt
|
|
14
14
|
def pull
|
15
15
|
STDOUT.sync = true
|
16
16
|
`#{configuration.before_pull}` if configuration.before_pull
|
17
|
+
puts ""
|
18
|
+
puts " Pulling files ".bright
|
19
|
+
puts ""
|
17
20
|
fetch_locales_to_pull.each do |locale|
|
18
21
|
configuration.files.find_all{ |file| file.locale == locale }.each do |file|
|
19
|
-
print "
|
22
|
+
print " * #{file.file_path}: "
|
20
23
|
puts file.fetch(command_options.force)
|
21
24
|
end
|
22
25
|
end
|
@@ -26,9 +29,12 @@ module WebTranslateIt
|
|
26
29
|
def push
|
27
30
|
STDOUT.sync = true
|
28
31
|
`#{configuration.before_push}` if configuration.before_push
|
32
|
+
puts ""
|
33
|
+
puts " Pushing files ".bright
|
34
|
+
puts ""
|
29
35
|
fetch_locales_to_push(configuration).each do |locale|
|
30
36
|
configuration.files.find_all{ |file| file.locale == locale }.each do |file|
|
31
|
-
print "
|
37
|
+
print " * #{file.file_path}... "
|
32
38
|
puts file.upload(command_options[:merge], command_options.ignore_missing, command_options.label, command_options.low_priority)
|
33
39
|
end
|
34
40
|
end
|
@@ -38,7 +44,7 @@ module WebTranslateIt
|
|
38
44
|
def add
|
39
45
|
STDOUT.sync = true
|
40
46
|
if parameters == []
|
41
|
-
puts "No master file given."
|
47
|
+
puts "No master file given.".failure
|
42
48
|
puts "Usage: wti add master_file1 master_file2 ..."
|
43
49
|
exit
|
44
50
|
end
|
@@ -47,27 +53,26 @@ module WebTranslateIt
|
|
47
53
|
print "Creating #{file.file_path}... "
|
48
54
|
puts file.create
|
49
55
|
end
|
50
|
-
puts "Master file added."
|
56
|
+
puts "Master file added.".success
|
51
57
|
end
|
52
58
|
|
53
59
|
def addlocale
|
54
60
|
STDOUT.sync = true
|
55
61
|
if parameters == []
|
56
|
-
puts "No locale code given."
|
62
|
+
puts "No locale code given.".failure
|
57
63
|
puts "Usage: wti addlocale locale1 locale2 ..."
|
58
64
|
exit
|
59
65
|
end
|
60
66
|
parameters.each do |param|
|
61
|
-
print "Adding locale #{param}... "
|
67
|
+
print "Adding locale #{param}... ".success
|
62
68
|
puts WebTranslateIt::Project.create_locale(configuration.api_key, param)
|
63
69
|
end
|
64
70
|
puts "Done!"
|
65
71
|
end
|
66
72
|
|
67
73
|
def init
|
68
|
-
|
69
|
-
|
70
|
-
path = Util.ask("Where should we put the configuration file?", 'config/translation.yml')
|
74
|
+
api_key = Util.ask("Project API Key:")
|
75
|
+
path = Util.ask("Configuration file path:", 'config/translation.yml')
|
71
76
|
FileUtils.mkpath(path.split('/')[0..path.split('/').size-2].join('/'))
|
72
77
|
project = YAML.load WebTranslateIt::Project.fetch_info(api_key)
|
73
78
|
project_info = project['project']
|
@@ -78,7 +83,7 @@ module WebTranslateIt
|
|
78
83
|
puts "Project File #{file['id']} doesn’t seem to be set up.".failure
|
79
84
|
error = true
|
80
85
|
elsif !File.exists?(file['name'])
|
81
|
-
puts "Could not find file `#{file['name']}
|
86
|
+
puts "Could not find file `#{file['name']}` locally."
|
82
87
|
error = true
|
83
88
|
else
|
84
89
|
puts "Found #{file['name']}.".success
|
@@ -90,7 +95,7 @@ module WebTranslateIt
|
|
90
95
|
else
|
91
96
|
puts ""
|
92
97
|
puts "Done! You can now use `wti` to push and pull your language files."
|
93
|
-
puts "Check `wti --help` for
|
98
|
+
puts "Check `wti --help` for help."
|
94
99
|
end
|
95
100
|
end
|
96
101
|
|
@@ -3,7 +3,6 @@ module WebTranslateIt
|
|
3
3
|
class Project
|
4
4
|
|
5
5
|
def self.fetch_info(api_key)
|
6
|
-
puts "Gathering project's information..." unless Object.const_defined?(:Spec)
|
7
6
|
begin
|
8
7
|
WebTranslateIt::Util.http_connection do |http|
|
9
8
|
request = Net::HTTP::Get.new("/api/projects/#{api_key}.yaml")
|
@@ -36,7 +36,7 @@ module WebTranslateIt
|
|
36
36
|
# file.fetch(true) # force to re-download the file, will return the content of the file with a 200 OK
|
37
37
|
#
|
38
38
|
def fetch(force = false)
|
39
|
-
print "#{self.local_checksum.checksumify}...#{self.remote_checksum.checksumify} "
|
39
|
+
print "#{self.local_checksum.to_s.checksumify}...#{self.remote_checksum.to_s.checksumify} "
|
40
40
|
if !File.exist?(self.file_path) or force or self.remote_checksum != self.local_checksum
|
41
41
|
begin
|
42
42
|
WebTranslateIt::Util.http_connection do |http|
|
@@ -47,16 +47,16 @@ module WebTranslateIt
|
|
47
47
|
File.open(self.file_path, 'wb'){ |file| file << response.body } if response.code.to_i == 200 and response.body != ''
|
48
48
|
Util.handle_response(response)
|
49
49
|
rescue
|
50
|
-
"
|
50
|
+
"/!\\ An error occured: #{$!}".failure
|
51
51
|
end
|
52
52
|
end
|
53
53
|
rescue Timeout::Error
|
54
|
-
puts "
|
54
|
+
puts "Request timeout. Will retry in 5 seconds.".failure
|
55
55
|
sleep(5)
|
56
56
|
fetch(force)
|
57
57
|
end
|
58
58
|
else
|
59
|
-
return "
|
59
|
+
return "Skipped (up to date)".success
|
60
60
|
end
|
61
61
|
end
|
62
62
|
|
@@ -80,13 +80,13 @@ module WebTranslateIt
|
|
80
80
|
Util.handle_response(http.request(request))
|
81
81
|
end
|
82
82
|
rescue Timeout::Error
|
83
|
-
puts "
|
83
|
+
puts "Request timeout. Will retry in 5 seconds.".failure
|
84
84
|
sleep(5)
|
85
85
|
upload(merge, ignore_missing)
|
86
86
|
end
|
87
87
|
end
|
88
88
|
else
|
89
|
-
puts "
|
89
|
+
puts "Can't push #{self.file_path}. File doesn't exist.".failure
|
90
90
|
end
|
91
91
|
end
|
92
92
|
|
@@ -110,7 +110,7 @@ module WebTranslateIt
|
|
110
110
|
Util.handle_response(http.request(request))
|
111
111
|
end
|
112
112
|
rescue Timeout::Error
|
113
|
-
puts "
|
113
|
+
puts "Request timeout. Will retry in 5 seconds.".failure
|
114
114
|
sleep(5)
|
115
115
|
create
|
116
116
|
end
|
@@ -46,15 +46,16 @@ module WebTranslateIt
|
|
46
46
|
|
47
47
|
def self.handle_response(response, return_response = false)
|
48
48
|
if response.code.to_i >= 400 and response.code.to_i < 500
|
49
|
-
"Can't
|
49
|
+
"Error: Can't find project for this API key.".failure
|
50
50
|
elsif response.code.to_i >= 500
|
51
|
-
"
|
51
|
+
"Error: Server temporarily unavailable. Please try again shortly.".failure
|
52
52
|
else
|
53
53
|
return response.body if return_response
|
54
|
-
return "
|
55
|
-
return "
|
56
|
-
return "
|
57
|
-
return "
|
54
|
+
return "Server currently processing file. Please retry later.".failure if response.code.to_i == 102
|
55
|
+
return "OK".success if response.code.to_i == 200
|
56
|
+
return "Created".success if response.code.to_i == 201
|
57
|
+
return "Accepted".success if response.code.to_i == 202
|
58
|
+
return "Not Modified".success if response.code.to_i == 304
|
58
59
|
end
|
59
60
|
end
|
60
61
|
|
@@ -46,8 +46,8 @@
|
|
46
46
|
<div class="contact">
|
47
47
|
<p>
|
48
48
|
<a href="http://docs.webtranslateit.com">Documentation</a><br/>
|
49
|
-
<a href="
|
50
|
-
<a href="
|
49
|
+
<a href="https://github.com/AtelierConvivialite/webtranslateit/">Source</a><br/>
|
50
|
+
<a href="https://github.com/AtelierConvivialite/webtranslateit/issues">Issues</a><br/>
|
51
51
|
<a href="http://twitter.com/webtranslateit">Twitter</a>
|
52
52
|
</p>
|
53
53
|
</div>
|
data/readme.md
CHANGED
@@ -1,7 +1,8 @@
|
|
1
|
-
|
1
|
+
Web Translate It
|
2
|
+
================
|
2
3
|
|
3
4
|
[Homepage](https://webtranslateit.com) |
|
4
|
-
[
|
5
|
+
[RDoc](http://yardoc.org/docs/AtelierConvivialite-webtranslateit) |
|
5
6
|
[Example app](http://github.com/AtelierConvivialite/rails_example_app) |
|
6
7
|
[Report a bug](http://github.com/AtelierConvivialite/webtranslateit/issues) |
|
7
8
|
[Support](http://help.webtranslateit.com)
|
@@ -16,7 +17,8 @@ This gem provides:
|
|
16
17
|
* a synchronisation server to help your translation team update your language files from a web interface,
|
17
18
|
* a rack middleware you can use within your Rails app to automatically fetch new translations from Web Translate It.
|
18
19
|
|
19
|
-
|
20
|
+
Installation
|
21
|
+
------------
|
20
22
|
|
21
23
|
These instructions are for Linux and Mac OS X system. Follow [these instructions](http://help.webtranslateit.com/kb/tips/how-to-install-wti-on-windows) if you’re using Microsoft Windows.
|
22
24
|
|
@@ -24,7 +26,8 @@ These instructions are for Linux and Mac OS X system. Follow [these instructions
|
|
24
26
|
|
25
27
|
At this point you should have the `wti` executable working.
|
26
28
|
|
27
|
-
|
29
|
+
Configuration
|
30
|
+
-------------
|
28
31
|
|
29
32
|
Now that the tool is installed, you’ll have to configure your project:
|
30
33
|
|
@@ -35,7 +38,8 @@ The tool will prompt for:
|
|
35
38
|
* your Web Translate It API key (you can find it in your project settings),
|
36
39
|
* where to save the configuration file (by default in `config/translations.yml`).
|
37
40
|
|
38
|
-
|
41
|
+
Usage
|
42
|
+
-----
|
39
43
|
|
40
44
|
Execute `wti --help` to see the usage:
|
41
45
|
|
@@ -74,11 +78,92 @@ You can get more information by appending `--help` after each command. For insta
|
|
74
78
|
--label, -b <s>: Apply a label to the changes
|
75
79
|
--help, -h: Show this message
|
76
80
|
|
77
|
-
|
81
|
+
Sample Commands
|
82
|
+
---------------
|
83
|
+
|
84
|
+
<table>
|
85
|
+
<tr>
|
86
|
+
<th>Command</th>
|
87
|
+
<th>Action</th>
|
88
|
+
</tr>
|
89
|
+
<tr>
|
90
|
+
<td>wti add path/to/master/file.po</td>
|
91
|
+
<td>Upload a new master language file</td>
|
92
|
+
</tr>
|
93
|
+
<tr>
|
94
|
+
<td>wti add file1.po file2.po file3.xml</td>
|
95
|
+
<td>Create several master language files at once, by specifying each file</td>
|
96
|
+
</tr>
|
97
|
+
<tr>
|
98
|
+
<td>wti add *.po</td>
|
99
|
+
<td>Create several master language files at once, by specifying an extension</td>
|
100
|
+
</tr>
|
101
|
+
<tr>
|
102
|
+
<td>wti push</td>
|
103
|
+
<td>Update a master language file</td>
|
104
|
+
</tr>
|
105
|
+
<tr>
|
106
|
+
<td>wti push -l fr</td>
|
107
|
+
<td>Update a target (French) language file</td>
|
108
|
+
</tr>
|
109
|
+
<tr>
|
110
|
+
<td>wti push -l "fr en da sv"</td>
|
111
|
+
<td>Update several target language files at once (French, English, Danish, Swedish)</td>
|
112
|
+
</tr>
|
113
|
+
<tr>
|
114
|
+
<td>wti push --all</td>
|
115
|
+
<td>Update all language files at once</td>
|
116
|
+
</tr>
|
117
|
+
<tr>
|
118
|
+
<td>wti pull</td>
|
119
|
+
<td>Download target language files</td>
|
120
|
+
</tr>
|
121
|
+
<tr>
|
122
|
+
<td>wti pull -l fr</td>
|
123
|
+
<td>Download a specific language file (French)</td>
|
124
|
+
</tr>
|
125
|
+
<tr>
|
126
|
+
<td>wti pull --all</td>
|
127
|
+
<td>Download all language files, including source</td>
|
128
|
+
</tr>
|
129
|
+
<tr>
|
130
|
+
<td>wti pull --force</td>
|
131
|
+
<td>Force pull (to bypass Web Translate It’s HTTP caching)</td>
|
132
|
+
</tr>
|
133
|
+
<tr>
|
134
|
+
<td>wti addlocale fr</td>
|
135
|
+
<td>Add a new locale to the project</td>
|
136
|
+
</tr>
|
137
|
+
<tr>
|
138
|
+
<td>wti addlocale fr da sv</td>
|
139
|
+
<td>Add several locales at once</td>
|
140
|
+
</tr>
|
141
|
+
<tr>
|
142
|
+
<td>wti status</td>
|
143
|
+
<td>View project statistics</td>
|
144
|
+
</tr>
|
145
|
+
</table>
|
146
|
+
|
147
|
+
Hooks
|
148
|
+
-----
|
149
|
+
|
150
|
+
It is sometimes useful to hook a command or a script before or after a push or a pull. One use-case would be to launch a build after pulling language files. You can do that by implementing hooks in your `translation.yml` file.
|
151
|
+
|
152
|
+
There are 4 hooks:
|
153
|
+
|
154
|
+
* `before_pull`
|
155
|
+
* `after_pull`
|
156
|
+
* `before_push`
|
157
|
+
* `after_push`
|
158
|
+
|
159
|
+
Check the [sample `translation.yml`](https://github.com/AtelierConvivialite/webtranslateit/blob/master/examples/translation.yml#L9..L13) file for implementation.
|
160
|
+
|
161
|
+
Web Translate It Synchronisation Console
|
162
|
+
----------------------------------------
|
78
163
|
|
79
164
|
![Web Translate It](http://s3.amazonaws.com:80/edouard.baconfile.com/web_translate_it%2Fadmin_console2.png)
|
80
165
|
|
81
|
-
|
166
|
+
`wti` contains a server you can use to run a friendly web interface to sync your translations. It allows a translation team to refresh the language files on a staging server without asking the developers to manually `wti pull`.
|
82
167
|
|
83
168
|
To get started, go to the directory of the application you want to sync and do:
|
84
169
|
|
@@ -88,77 +173,13 @@ By default, it starts an application on localhost on the port 4000. You will fin
|
|
88
173
|
|
89
174
|
Should you need to use another host or port, you can use the `-h` and `-p` options. For example: `wti server -p 1234`.
|
90
175
|
|
91
|
-
You may want to run some commands before or after syncing translations.
|
176
|
+
You may want to run some commands before or after syncing translations. You can use the hooks to do so. For instance, you could add the following in your `translation.yml` file:
|
92
177
|
|
93
178
|
before_pull: "echo 'some unix command'"
|
94
179
|
after_pull: "touch tmp/restart.txt"
|
95
180
|
|
96
181
|
`before_pull` and `after_pull` are respectively executed before and after pulling language files.
|
97
182
|
|
98
|
-
## Use Cases
|
99
|
-
|
100
|
-
Here are some example commands for the most common scenarios.
|
101
|
-
|
102
|
-
### Upload a new master language file
|
103
|
-
|
104
|
-
wti add path/to/master/file.po
|
105
|
-
|
106
|
-
Create several master language files at once:
|
107
|
-
|
108
|
-
wti add file1.po file2.po file3.xml
|
109
|
-
|
110
|
-
Or:
|
111
|
-
|
112
|
-
wti add *.po
|
113
|
-
|
114
|
-
After receiving your master language files, Web Translate It will automatically create the corresponding target files. If you have already some translations for these files, use `wti push --all` to synchronise them to Web Translate It.
|
115
|
-
|
116
|
-
### Update a master language file
|
117
|
-
|
118
|
-
wti push
|
119
|
-
|
120
|
-
### Update a target language file
|
121
|
-
|
122
|
-
Update the french language file:
|
123
|
-
|
124
|
-
wti push -l fr
|
125
|
-
|
126
|
-
Or several languages at once:
|
127
|
-
|
128
|
-
wti push -l "fr en da sv"
|
129
|
-
|
130
|
-
### Update all language files at once
|
131
|
-
|
132
|
-
wti push --all
|
133
|
-
|
134
|
-
### Download target language files
|
135
|
-
|
136
|
-
wti pull
|
137
|
-
|
138
|
-
### Download a specific language file
|
139
|
-
|
140
|
-
wti pull -l fr
|
141
|
-
|
142
|
-
### Download all language files, including source
|
143
|
-
|
144
|
-
wti pull --all
|
145
|
-
|
146
|
-
### Force pull (to bypass Web Translate It’s HTTP caching)
|
147
|
-
|
148
|
-
wti pull --force
|
149
|
-
|
150
|
-
### Add a new locale to the project
|
151
|
-
|
152
|
-
wti addlocale fr
|
153
|
-
|
154
|
-
Or add several locales at once:
|
155
|
-
|
156
|
-
wti addlocale fr da sv
|
157
|
-
|
158
|
-
### View project stats
|
159
|
-
|
160
|
-
wti status
|
161
|
-
|
162
183
|
# License
|
163
184
|
|
164
185
|
Copyright (c) 2009-2011 Atelier Convivialité, released under the MIT License.
|
@@ -18,21 +18,21 @@ describe WebTranslateIt::TranslationFile do
|
|
18
18
|
file = mock(File)
|
19
19
|
file.stub(:puts => true, :close => true)
|
20
20
|
File.stub(:exist? => true, :mtime => Time.at(0), :new => file)
|
21
|
-
translation_file.fetch.should include "
|
21
|
+
translation_file.fetch.should include "OK"
|
22
22
|
end
|
23
23
|
|
24
24
|
it "should prepare a HTTP request and get a 200 OK if the language file is stale using the force download parameter" do
|
25
25
|
file = mock(File)
|
26
26
|
file.stub(:puts => true, :close => true)
|
27
27
|
File.stub(:exist? => true, :mtime => Time.at(0), :new => file)
|
28
|
-
translation_file.fetch(true).should include "
|
28
|
+
translation_file.fetch(true).should include "OK"
|
29
29
|
end
|
30
30
|
|
31
31
|
it "should prepare a HTTP request and get a 200 OK if the language file is fresh using the force download parameter" do
|
32
32
|
file = mock(File)
|
33
33
|
file.stub(:puts => true, :close => true)
|
34
34
|
File.stub(:exist? => true, :mtime => Time.now, :new => file)
|
35
|
-
translation_file.fetch(true).should include "
|
35
|
+
translation_file.fetch(true).should include "OK"
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
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: 105
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
7
|
- 1
|
8
8
|
- 7
|
9
9
|
- 3
|
10
|
-
-
|
11
|
-
version: 1.7.3.
|
10
|
+
- 1
|
11
|
+
version: 1.7.3.1
|
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-05-06 00:00:00 +02:00
|
20
20
|
default_executable: wti
|
21
21
|
dependencies:
|
22
22
|
- !ruby/object:Gem::Dependency
|
@@ -59,12 +59,12 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - ~>
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
hash:
|
62
|
+
hash: 19
|
63
63
|
segments:
|
64
64
|
- 1
|
65
65
|
- 2
|
66
|
-
-
|
67
|
-
version: 1.2.
|
66
|
+
- 6
|
67
|
+
version: 1.2.6
|
68
68
|
type: :runtime
|
69
69
|
version_requirements: *id003
|
70
70
|
- !ruby/object:Gem::Dependency
|