web_translate_it 1.7.1.7 → 1.7.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +90 -118
- data/bin/wti +48 -128
- data/examples/en.yml +38 -0
- data/examples/translation.yml +7 -0
- data/history.md +13 -0
- data/lib/web_translate_it/command_line.rb +58 -33
- data/lib/web_translate_it/configuration.rb +3 -1
- data/lib/web_translate_it/server.rb +0 -6
- data/lib/web_translate_it/translation_file.rb +7 -7
- data/lib/web_translate_it/util.rb +26 -9
- data/man/wti.1 +27 -30
- data/man/wti.1.html +87 -78
- data/man/wti.1.ron +3 -3
- data/readme.md +90 -118
- data/spec/web_translate_it/translation_file_spec.rb +4 -4
- data/version.yml +2 -2
- metadata +29 -12
data/README.md
CHANGED
@@ -4,19 +4,17 @@
|
|
4
4
|
[RDocs](http://yardoc.org/docs/AtelierConvivialite-webtranslateit) |
|
5
5
|
[Example app](http://github.com/AtelierConvivialite/rails_example_app) |
|
6
6
|
[Report a bug](http://github.com/AtelierConvivialite/webtranslateit/issues) |
|
7
|
-
[Support](http://help.webtranslateit.com)
|
8
|
-
[Documentation](http://docs.webtranslateit.com/web_translate_it_client/)
|
7
|
+
[Support](http://help.webtranslateit.com)
|
9
8
|
|
10
9
|
`web_translate_it` is a rubygem providing tools to sync your language files with [Web Translate It](https://webtranslateit.com), a web-based computer-aided translation tool.
|
11
10
|
|
12
11
|
![Web Translate It](http://s3.amazonaws.com:80/edouard.baconfile.com/web_translate_it%2Fwti2.png)
|
13
12
|
|
14
|
-
This gem provides
|
13
|
+
This gem provides:
|
15
14
|
|
16
|
-
*
|
17
|
-
* a synchronisation server to help your translation team update your language files from a web
|
18
|
-
* a
|
19
|
-
* a rack middleware to automatically fetch new translations from Web Translate It.
|
15
|
+
* a command-line executable `wti`, to sync your files between your computer/server and WebTranslateIt.com,
|
16
|
+
* a synchronisation server to help your translation team update your language files from a web interface,
|
17
|
+
* a rack middleware you can use within your Rails app to automatically fetch new translations from Web Translate It.
|
20
18
|
|
21
19
|
## Installation
|
22
20
|
|
@@ -25,168 +23,142 @@ These instructions are for Linux and Mac OS X system. Follow [these instructions
|
|
25
23
|
gem install web_translate_it
|
26
24
|
|
27
25
|
At this point you should have the `wti` executable working.
|
28
|
-
If your project if already set up on Web Translate It, open a terminal and type `wti autoconf` to generate the configuration file.
|
29
|
-
|
30
|
-
Execute `wti --help` to see the usage:
|
31
|
-
|
32
|
-
Usage: wti [-lcphhv]
|
33
|
-
pull Pull target language file(s)
|
34
|
-
push Push master language file(s)
|
35
|
-
add Create and push a new master language file
|
36
|
-
addlocale Add a new locale to the project
|
37
|
-
server Start a synchronisation server
|
38
|
-
stats Fetch and display project statistics
|
39
|
-
autoconf Configure your project to sync
|
40
|
-
|
41
|
-
Synchronization options:
|
42
|
-
-l, --locale ISO code of a locale to pull or push
|
43
|
-
-c, --config Path to a translation.yml file
|
44
|
-
(default: config/translation.yml)
|
45
|
-
--all Download or upload all files
|
46
|
-
--force Force wti pull to download files
|
47
|
-
--merge Force WTI to merge this file
|
48
|
-
--ignore_missing Force WTI to not obsolete missing strings
|
49
|
-
--low_priority Tells WTI to process this command with a low priority
|
50
|
-
--label Apply a label to the changes
|
51
|
-
|
52
|
-
Server options:
|
53
|
-
-p, --port Run server on a specific port
|
54
|
-
(default: 4000)
|
55
|
-
-h, --host Run server on a specific host
|
56
|
-
(default: localhost)
|
57
|
-
|
58
|
-
Other options:
|
59
|
-
-h, --help Show this message
|
60
|
-
-v, --version Show version
|
61
26
|
|
62
27
|
## Configuration
|
63
28
|
|
64
29
|
Now that the tool is installed, you’ll have to configure your project:
|
65
30
|
|
66
|
-
wti
|
31
|
+
wti init
|
67
32
|
|
68
|
-
|
33
|
+
The tool will prompt for:
|
69
34
|
|
70
|
-
|
35
|
+
* your Web Translate It API key (you can find it in your project settings),
|
36
|
+
* where to save the configuration file (by default in `config/translations.yml`).
|
71
37
|
|
72
|
-
|
38
|
+
## Usage
|
73
39
|
|
74
|
-
|
40
|
+
Execute `wti --help` to see the usage:
|
75
41
|
|
76
|
-
wti
|
42
|
+
wti is a command line tool to sync your local translation files
|
43
|
+
with the WebTranslateIt.com service.
|
77
44
|
|
78
|
-
|
45
|
+
Usage:
|
46
|
+
wti <command> [options]+
|
47
|
+
|
48
|
+
<command> is one of: pull push add addlocale server stats status st autoconf init
|
49
|
+
[options] are:
|
50
|
+
--config, -c <s>: Path to a translation.yml file (default:
|
51
|
+
config/translation.yml)
|
52
|
+
--version, -v: Print version and exit
|
53
|
+
--help, -h: Show this message
|
54
|
+
|
55
|
+
Here’s more explanation about the commands.
|
56
|
+
|
57
|
+
pull Pull target language file(s)
|
58
|
+
push Push master language file(s)
|
59
|
+
add Create and push a new master language file
|
60
|
+
addlocale Add a new locale to the project
|
61
|
+
server Start a synchronisation server
|
62
|
+
status Fetch and display project statistics
|
63
|
+
init Configure your project to sync
|
64
|
+
|
65
|
+
You can get more information by appending `--help` after each command. For instance:
|
66
|
+
|
67
|
+
$ wti push --help
|
68
|
+
Options:
|
69
|
+
--locale, -l <s>: ISO code of a locale to push
|
70
|
+
--all, -a: Upload all files
|
71
|
+
--low-priority, -o: WTI will process this file with a low priority
|
72
|
+
--merge, -m: Force WTI to merge this file
|
73
|
+
--ignore-missing, -i: Force WTI to not obsolete missing strings
|
74
|
+
--label, -b <s>: Apply a label to the changes
|
75
|
+
--help, -h: Show this message
|
79
76
|
|
80
|
-
|
77
|
+
## Web Translate It Synchronisation Console
|
81
78
|
|
82
|
-
|
79
|
+
![Web Translate It](http://s3.amazonaws.com:80/edouard.baconfile.com/web_translate_it%2Fadmin_console2.png)
|
83
80
|
|
84
|
-
|
81
|
+
The `wti` gem integrates since its version 1.7.0 a sinatra app that provides you with 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`.
|
85
82
|
|
86
|
-
|
83
|
+
To get started, go to the directory of the application you want to sync and do:
|
87
84
|
|
88
|
-
|
85
|
+
wti server
|
89
86
|
|
90
|
-
|
87
|
+
By default, it starts an application on localhost on the port 4000. You will find the tool on `http://localhost:4000`.
|
91
88
|
|
92
|
-
|
89
|
+
Should you need to use another host or port, you can use the `-h` and `-p` options. For example: `wti server -p 1234`.
|
93
90
|
|
94
|
-
|
95
|
-
|
96
|
-
where `fr` should be replaced by the locale code of your file.
|
91
|
+
You may want to run some commands before or after syncing translations. To do so, add in the `translation.yml` file the following:
|
97
92
|
|
98
|
-
|
93
|
+
before_pull: "echo 'some unix command'"
|
94
|
+
after_pull: "touch tmp/restart.txt"
|
99
95
|
|
100
|
-
|
96
|
+
`before_pull` and `after_pull` are respectively executed before and after pulling language files.
|
101
97
|
|
102
|
-
|
98
|
+
## Use Cases
|
103
99
|
|
104
|
-
|
105
|
-
|
106
|
-
### Download a specific language file
|
100
|
+
Here are some example commands for the most common scenarios.
|
107
101
|
|
108
|
-
|
109
|
-
|
110
|
-
### Download all the language files
|
102
|
+
### Upload a new master language file
|
111
103
|
|
112
|
-
wti
|
113
|
-
|
114
|
-
### Force pull (bypass Web Translate It’s HTTP caching)
|
104
|
+
wti add path/to/master/file.po
|
115
105
|
|
116
|
-
|
106
|
+
Create several master language files at once:
|
117
107
|
|
118
|
-
|
108
|
+
wti add file1.po file2.po file3.xml
|
119
109
|
|
120
|
-
|
121
|
-
|
122
|
-
## Web Translate It Synchronisation Console
|
110
|
+
Or:
|
123
111
|
|
124
|
-
|
112
|
+
wti add *.po
|
125
113
|
|
126
|
-
|
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.
|
127
115
|
|
128
|
-
|
116
|
+
### Update a master language file
|
129
117
|
|
130
|
-
wti
|
131
|
-
|
132
|
-
By default, it starts an application on localhost on the port 4000. You will find the tool on `http://localhost:4000`.
|
118
|
+
wti push
|
133
119
|
|
134
|
-
|
120
|
+
### Update a target language file
|
135
121
|
|
136
|
-
|
122
|
+
Update the french language file:
|
137
123
|
|
138
|
-
|
139
|
-
after_pull: "touch tmp/restart.txt"
|
124
|
+
wti push -l fr
|
140
125
|
|
141
|
-
|
126
|
+
Or several languages at once:
|
142
127
|
|
143
|
-
|
128
|
+
wti push -l "fr en da sv"
|
129
|
+
|
130
|
+
### Update all language files at once
|
144
131
|
|
145
|
-
|
132
|
+
wti push --all
|
146
133
|
|
147
|
-
|
134
|
+
### Download target language files
|
148
135
|
|
149
|
-
|
136
|
+
wti pull
|
150
137
|
|
151
|
-
|
152
|
-
|
153
|
-
`rake gems:install`
|
138
|
+
### Download a specific language file
|
154
139
|
|
155
|
-
|
140
|
+
wti pull -l fr
|
141
|
+
|
142
|
+
### Download all language files, including source
|
156
143
|
|
157
|
-
|
144
|
+
wti pull --all
|
158
145
|
|
159
|
-
|
160
|
-
|
161
|
-
- It adds a auto-configured `config/translation.yml` file using Web Translate It’s API.
|
162
|
-
- It adds `require 'web_translate_it/tasks' rescue LoadError` to your `Rakefile`
|
163
|
-
|
164
|
-
There are 3 rake tasks.
|
146
|
+
### Force pull (to bypass Web Translate It’s HTTP caching)
|
165
147
|
|
166
|
-
|
167
|
-
|
168
|
-
Fetch the latest translations for all your files for all languages defined in Web Translate It’s interface, except for the languages set in `ignore_locales`.
|
148
|
+
wti pull --force
|
169
149
|
|
170
|
-
|
171
|
-
|
172
|
-
Fetch the latest translations for all the languages defined in Web Translate It’s interface. It takes the locale name as a parameter
|
150
|
+
### Add a new locale to the project
|
173
151
|
|
174
|
-
|
152
|
+
wti addlocale fr
|
175
153
|
|
176
|
-
|
177
|
-
|
178
|
-
Read more about [Rails integration in the wiki](http://wiki.github.com/AtelierConvivialite/webtranslateit/).
|
154
|
+
Or add several locales at once:
|
179
155
|
|
180
|
-
|
156
|
+
wti addlocale fr da sv
|
181
157
|
|
182
|
-
|
183
|
-
|
184
|
-
* 2.3.4
|
185
|
-
* 2.3.5
|
186
|
-
* 2.3.10
|
158
|
+
### View project stats
|
187
159
|
|
188
|
-
|
160
|
+
wti status
|
189
161
|
|
190
162
|
# License
|
191
163
|
|
192
|
-
Copyright (c) 2009-2011 Atelier Convivialité,
|
164
|
+
Copyright (c) 2009-2011 Atelier Convivialité, released under the MIT License.
|
data/bin/wti
CHANGED
@@ -1,136 +1,56 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
2
|
|
3
|
-
require '
|
3
|
+
require 'trollop'
|
4
4
|
require 'web_translate_it'
|
5
5
|
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
option :addlocale do
|
24
|
-
long 'addlocale'
|
25
|
-
desc "Add a new locale to the project"
|
26
|
-
end
|
27
|
-
|
28
|
-
option :server do
|
29
|
-
long 'server'
|
30
|
-
desc "Start a synchronisation server"
|
31
|
-
end
|
32
|
-
|
33
|
-
option :stats do
|
34
|
-
long 'stats'
|
35
|
-
desc "Fetch and display project statistics"
|
36
|
-
end
|
37
|
-
|
38
|
-
option :autoconf do
|
39
|
-
long 'autoconf'
|
40
|
-
desc "Configure your project to sync"
|
41
|
-
end
|
42
|
-
|
43
|
-
separator ''
|
44
|
-
separator 'Synchronization options: '
|
45
|
-
|
46
|
-
option :locale do
|
47
|
-
short '-l'
|
48
|
-
long '--locale'
|
49
|
-
desc "ISO code of a locale to pull or push"
|
50
|
-
end
|
51
|
-
|
52
|
-
option :config do
|
53
|
-
short '-c'
|
54
|
-
long '--config'
|
55
|
-
desc "Path to a translation.yml file"
|
56
|
-
desc "(default: config/translation.yml)"
|
57
|
-
default "config/translation.yml"
|
58
|
-
end
|
59
|
-
|
60
|
-
option :all do
|
61
|
-
long '--all'
|
62
|
-
desc "Download or upload all files"
|
63
|
-
end
|
64
|
-
|
65
|
-
option :force do
|
66
|
-
long '--force'
|
67
|
-
desc "Force wti pull to download files"
|
68
|
-
end
|
69
|
-
|
70
|
-
option :merge do
|
71
|
-
long '--merge'
|
72
|
-
desc "Force WTI to merge this file"
|
73
|
-
end
|
74
|
-
|
75
|
-
option :ignore_missing do
|
76
|
-
long '--ignore_missing'
|
77
|
-
desc "Force WTI to not obsolete missing strings"
|
78
|
-
end
|
79
|
-
|
80
|
-
option :low_priority do
|
81
|
-
long '--low_priority'
|
82
|
-
desc "Tells WTI to process this command with a low priority"
|
83
|
-
end
|
84
|
-
|
85
|
-
option :label do
|
86
|
-
long '--label'
|
87
|
-
desc "Apply a label to the changes"
|
88
|
-
end
|
89
|
-
|
90
|
-
separator ''
|
91
|
-
separator 'Server options: '
|
92
|
-
|
93
|
-
option :port do
|
94
|
-
short '-p'
|
95
|
-
long '--port'
|
96
|
-
desc "Run server on a specific port"
|
97
|
-
desc "(default: 4000)"
|
98
|
-
cast Integer
|
99
|
-
default '4000'
|
100
|
-
end
|
101
|
-
|
102
|
-
option :host do
|
103
|
-
short '-h'
|
104
|
-
long '--host'
|
105
|
-
desc "Run server on a specific host"
|
106
|
-
desc "(default: localhost)"
|
107
|
-
default '0.0.0.0'
|
108
|
-
end
|
109
|
-
|
110
|
-
separator ''
|
111
|
-
separator 'Other options: '
|
112
|
-
|
113
|
-
option :help do
|
114
|
-
short '-h'
|
115
|
-
long '--help'
|
116
|
-
desc 'Show this message'
|
117
|
-
end
|
6
|
+
SUB_COMMANDS = %w(pull push add addlocale server stats status st autoconf init)
|
7
|
+
global_options = Trollop::options do
|
8
|
+
banner <<-EOS
|
9
|
+
wti is a command line tool to sync your local translation files
|
10
|
+
with the WebTranslateIt.com service.
|
11
|
+
|
12
|
+
Usage:
|
13
|
+
wti <command> [options]+
|
14
|
+
|
15
|
+
<command> is one of: #{SUB_COMMANDS.join(" ")}
|
16
|
+
[options] are:
|
17
|
+
EOS
|
18
|
+
version "Web Translate It v#{WebTranslateIt::Util.version}"
|
19
|
+
opt :config, "Path to a translation.yml file", :short => "-c", :default => "config/translation.yml"
|
20
|
+
stop_on SUB_COMMANDS
|
21
|
+
end
|
118
22
|
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
23
|
+
command = ARGV.shift # get the subcommand
|
24
|
+
command_options = case command
|
25
|
+
when "pull"
|
26
|
+
Trollop::options do
|
27
|
+
opt :locale, "ISO code of locale(s) to pull", :type => :string
|
28
|
+
opt :all, "Pull all files"
|
29
|
+
opt :force, "Force pull (bypass conditional requests to WTI)"
|
30
|
+
end
|
31
|
+
when "push"
|
32
|
+
Trollop::options do
|
33
|
+
opt :locale, "ISO code of locale(s) to push", :type => :string
|
34
|
+
opt :all, "Upload all files"
|
35
|
+
opt :low_priority, "WTI will process this file with a low priority"
|
36
|
+
opt :merge, "Force WTI to merge this file"
|
37
|
+
opt :ignore_missing, "Force WTI to not obsolete missing strings"
|
38
|
+
opt :label, "Apply a label to the changes", :type => :string
|
127
39
|
end
|
40
|
+
when "add"
|
41
|
+
when "addlocale"
|
42
|
+
when "server"
|
43
|
+
Trollop::options do
|
44
|
+
opt :port, "Run server on a specific port", :default => 4000, :short => "-p"
|
45
|
+
opt :host, "Run server on a specific host", :default => "0.0.0.0", :short => "-h"
|
46
|
+
end
|
47
|
+
when "stats"
|
48
|
+
when "status"
|
49
|
+
when "st"
|
50
|
+
when "autoconf"
|
51
|
+
when "init"
|
52
|
+
else
|
53
|
+
Trollop::die "unknown subcommand #{command.inspect}"
|
128
54
|
end
|
129
|
-
end
|
130
55
|
|
131
|
-
|
132
|
-
$project_path = File.expand_path(".")
|
133
|
-
$command = Choice.rest[0]
|
134
|
-
$parameters = Choice.rest[1..-1]
|
135
|
-
Choice.help if $command.nil?
|
136
|
-
WebTranslateIt::CommandLine.new($command, options, $project_path, $parameters)
|
56
|
+
WebTranslateIt::CommandLine.new(command, command_options, global_options, ARGV, File.expand_path("."))
|
data/examples/en.yml
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
en:
|
2
|
+
activerecord:
|
3
|
+
errors:
|
4
|
+
templates:
|
5
|
+
header:
|
6
|
+
one: "1 error prohibited this {{model}} from being saved"
|
7
|
+
other: "{{count}} errors prohibited this {{model}} from being saved"
|
8
|
+
body: "there were problems with the following fields:"
|
9
|
+
messages:
|
10
|
+
accepted: "must be accepted"
|
11
|
+
blank: "can't be blank"
|
12
|
+
confirmation: "doesn't match confirmation"
|
13
|
+
empty: "can't be empty"
|
14
|
+
equal_to: "must be equal to {{count}}"
|
15
|
+
even: "must be even"
|
16
|
+
exclusion: "is reserved"
|
17
|
+
greater_than: "must be greater than {{count}}"
|
18
|
+
greater_than_or_equal_to: "must be greater than or equal to {{count}}"
|
19
|
+
inclusion: "is not included in the list"
|
20
|
+
invalid: "is invalid"
|
21
|
+
less_than: "must be less than {{count}}"
|
22
|
+
less_than_or_equal_to: "must be less than or equal to {{count}}"
|
23
|
+
not_a_number: "is not a number"
|
24
|
+
odd: "must be odd"
|
25
|
+
taken: "is already taken"
|
26
|
+
too_long: "is too long (maximum is {{count}} characters)"
|
27
|
+
too_short: "is too short (minimum is {{count}} characters)"
|
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/examples/translation.yml
CHANGED
@@ -4,3 +4,10 @@ api_key: SECRET
|
|
4
4
|
# Optional: locales not to sync with Web Translate It.
|
5
5
|
# eg. [:en, :fr] or just 'en'
|
6
6
|
# ignore_locales: :en
|
7
|
+
|
8
|
+
# Optional
|
9
|
+
# before_pull: "echo 'some unix command'" # Command executed before pulling files
|
10
|
+
# after_pull: "touch tmp/restart.txt" # Command executed after pulling files
|
11
|
+
#
|
12
|
+
# before_push: "echo 'some unix command'" # Command executed before pushing files
|
13
|
+
# after_push: "touch tmp/restart.txt" # Command executed after pushing files
|
data/history.md
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
## Version 1.7.2.0 / 2011-03-10
|
2
|
+
|
3
|
+
* Deprecate `wti autoconf` in favour of `wti init`.
|
4
|
+
* Deprecate `wti stats` in favour of `wti status` and its alias `wti st`.
|
5
|
+
* Better help and options. Replaced option parser from Choice to Trollop.
|
6
|
+
* `wti pull -l` can now take several locales separated by spaces.
|
7
|
+
For instance: `wti pull -l "en fr ja"`
|
8
|
+
* `wti push -l` can now take several locales separated by spaces.
|
9
|
+
For instance: `wti push -l "en fr"`
|
10
|
+
* New: Coloured terminal output.
|
11
|
+
* New: `before_pull` and `after_pull` hooks now work for all kind of `wti pull` (not only within `wti server`).
|
12
|
+
* New: Added 2 new hooks: `before_push` and `after_push`.
|
13
|
+
|
1
14
|
## Version 1.7.1.7 / 2011-03-07
|
2
15
|
|
3
16
|
* New: `wti unknow_command` explains how to get help.
|