web_translate_it 1.7.0.2 → 1.7.0.3

Sign up to get free protection for your applications and to get access to all the features.
data/README.md CHANGED
@@ -7,15 +7,15 @@
7
7
  [Support](http://help.webtranslateit.com)
8
8
  [Documentation](http://docs.webtranslateit.com/web_translate_it_client/)
9
9
 
10
- This is a gem providing tools to sync your software’s language files with [Web Translate It](https://webtranslateit.com), a web-based computer-aided translation tool.
10
+ `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
11
 
12
12
  ![Web Translate It](http://s3.amazonaws.com:80/edouard.baconfile.com/web_translate_it%2Fwti.png)
13
13
 
14
- This gem provides your app with:
14
+ This gem provides 4 tools:
15
15
 
16
- * an executable, `wti`, that will help you to upload and download language files from the command line (or in whatever else you want to execute it),
17
- * a handful of rake task to fetch and upload your translations,
18
- * a Sinatra app to help you download your translations from a web-based interface,
16
+ * an executable, `wti`, that will help you to upload and download language files from the command line,
17
+ * a synchronisation server to help your translation team update your language files from a web-based interface,
18
+ * a handful of rake task you can use with your Ruby on Rails application,
19
19
  * a rack middleware to automatically fetch new translations from Web Translate It.
20
20
 
21
21
  ## Installation
@@ -25,41 +25,60 @@ This gem provides your app with:
25
25
  At this point you should have the `wti` executable working.
26
26
  If your project if already set up on Web Translate It, open a terminal and type `wti autoconf` to generate the configuration file.
27
27
 
28
- Run `wti --help` to see the usage:
28
+ Execute `wti --help` to see the usage:
29
29
 
30
- pull Pull target language file(s) from Web Translate It.
31
- push Push master language file(s) to Web Translate It.
32
- autoconf Configure your project to sync with Web Translate It.
33
- stats Fetch and display your project statistics.
30
+ Usage: wti [-lcphv]
31
+ pull Pull target language file(s).
32
+ push Push master language file(s).
33
+ add Create and push a new master language file.
34
+ server Start a synchronisation server
35
+ stats Fetch and display project statistics.
36
+ autoconf Configure your project to sync.
34
37
 
35
- OPTIONAL PARAMETERS:
36
- --------------------
37
- -l --locale The ISO code of a specific locale to pull or push.
38
- -c --config Path to a translation.yml file. If this option
39
- is absent, looks for config/translation.yml.
40
- --all Respectively download or upload all files.
41
- --force Force wti pull to re-download the language file,
42
- regardless if local version is current.
43
- OTHER:
44
- ------
45
- -v --version Show version.
46
- -h --help This page.
38
+ Synchronization options:
39
+ -l, --locale ISO code of a locale to pull or push.
40
+ -c, --config Path to a translation.yml file.
41
+ (default: config/translation.yml).
42
+ --all Download or upload all files.
43
+ --force Force wti pull to download files.
44
+ --merge Force WTI to merge this file.
45
+ --ignore_missing Force WTI to not obsolete missing strings.
47
46
 
48
- ## Generalities
47
+ Server options:
48
+ -p, --port Run server on a specific port
49
+ (default: 4000).
50
+ -h, --host Run server on a specific host
51
+ (default: localhost).
49
52
 
50
- The first time, you’ll have to configure your project:
53
+ Other options:
54
+ --help Show this message
55
+ -v, --version Show version
56
+
57
+ ## Configuration
58
+
59
+ Now that the tool is installed, you’ll have to configure your project:
51
60
 
52
61
  wti autoconf
53
-
62
+
54
63
  It will ask for your Web Translate It API key, and where to save its configuration file. Letting it put in `config/translations.yml` makes everything easier.
55
64
 
65
+ ## Usage
66
+
56
67
  ### Uploading your first language file
57
68
 
58
69
  If you have no file on Web Translate It yet, you need to send us your master language files. You can do it from the web interface, or from the command line:
59
70
 
60
71
  wti add path/to/master/file.po
61
72
 
62
- That’s it! Web Translate It will automatically create the corresponding target files.
73
+ You can also add several files at once:
74
+
75
+ wti add file1.po file2.po file3.xml
76
+
77
+ Or
78
+
79
+ wti add *.po
80
+
81
+ After receiving your master language files, Web Translate It will automatically create the corresponding, empty target files. If you have already some translations for these files, use `wti push --all` to synchronise them to Web Translate It.
63
82
 
64
83
  ### Updating a master language file
65
84
 
@@ -69,7 +88,11 @@ That’s it! Web Translate It will automatically create the corresponding target
69
88
 
70
89
  wti push -l fr
71
90
 
72
- where fr should be replaced by the locale code of your file.
91
+ where `fr` should be replaced by the locale code of your file.
92
+
93
+ ### Updating all language files
94
+
95
+ wti push --all
73
96
 
74
97
  ### Download target language files
75
98
 
@@ -108,7 +131,7 @@ Should you need to use another host or port, you can use the -h and -p options.
108
131
  You may want to run some commands before or after synching translations. To do so, add in the `translation.yml` file the following:
109
132
 
110
133
  before_pull: "echo 'some unix command'"
111
- after_pull: "touch public/restart.txt"
134
+ after_pull: "touch tmp/restart.txt"
112
135
 
113
136
  `before_pull` and `after_pull` will respectively be executed before and after pulling your language files.
114
137
 
@@ -167,7 +190,7 @@ Please open a discussion on [our support site](http://help.webtranslateit.com) i
167
190
 
168
191
  # What is Web Translate It anyway?
169
192
 
170
- Web Translate It is a web-based translation tool to collaboratively translate software.
193
+ [Web Translate It](https://webtranslateit.com) is a web-based computer-aided translation tool to collaboratively translate software.
171
194
 
172
195
  To learn more about it, please visit our [tour page](https://webtranslateit.com/tour).
173
196
 
data/bin/wti CHANGED
@@ -1,4 +1,121 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
+ require 'choice'
3
4
  require 'web_translate_it'
4
- WebTranslateIt::CommandLine.run
5
+
6
+ Choice.options do
7
+
8
+ option :pull do
9
+ long 'pull'
10
+ desc "Pull target language file(s)."
11
+ end
12
+
13
+ option :push do
14
+ long 'push'
15
+ desc "Push master language file(s)."
16
+ end
17
+
18
+ option :add do
19
+ long 'add'
20
+ desc "Create and push a new master language file."
21
+ end
22
+
23
+ option :server do
24
+ long 'server'
25
+ desc "Start a synchronisation server"
26
+ end
27
+
28
+ option :stats do
29
+ long 'stats'
30
+ desc "Fetch and display project statistics."
31
+ end
32
+
33
+ option :autoconf do
34
+ long 'autoconf'
35
+ desc "Configure your project to sync."
36
+ end
37
+
38
+ separator ''
39
+ separator 'Synchronization options: '
40
+
41
+ option :locale do
42
+ short '-l'
43
+ long '--locale'
44
+ desc "ISO code of a locale to pull or push."
45
+ end
46
+
47
+ option :config do
48
+ short '-c'
49
+ long '--config'
50
+ desc "Path to a translation.yml file."
51
+ desc "(default: config/translation.yml)."
52
+ default "config/translation.yml"
53
+ end
54
+
55
+ option :all do
56
+ long '--all'
57
+ desc "Download or upload all files."
58
+ end
59
+
60
+ option :force do
61
+ long '--force'
62
+ desc "Force wti pull to download files."
63
+ end
64
+
65
+ option :merge do
66
+ long '--merge'
67
+ desc "Force WTI to merge this file."
68
+ end
69
+
70
+ option :ignore_missing do
71
+ long '--ignore_missing'
72
+ desc "Force WTI to not obsolete missing strings."
73
+ end
74
+
75
+ separator ''
76
+ separator 'Server options: '
77
+
78
+ option :port do
79
+ short '-p'
80
+ long '--port'
81
+ desc "Run server on a specific port"
82
+ desc "(default: 4000)."
83
+ cast Integer
84
+ default '4000'
85
+ end
86
+
87
+ option :host do
88
+ short '-h'
89
+ long '--host'
90
+ desc "Run server on a specific host"
91
+ desc "(default: localhost)."
92
+ default '0.0.0.0'
93
+ end
94
+
95
+ separator ''
96
+ separator 'Other options: '
97
+
98
+ option :help do
99
+ short '-h'
100
+ long '--help'
101
+ desc 'Show this message'
102
+ end
103
+
104
+ option :version do
105
+ short '-v'
106
+ long '--version'
107
+ desc 'Show version'
108
+ action do
109
+ puts ""
110
+ puts "Web Translate It #{WebTranslateIt::Util.version}"
111
+ exit
112
+ end
113
+ end
114
+ end
115
+
116
+ options = Choice.choices
117
+ $project_path = File.expand_path(".")
118
+ $command = Choice.rest[0]
119
+ $parameters = Choice.rest[1..-1]
120
+ Choice.help if $command.nil?
121
+ WebTranslateIt::CommandLine.new($command, options, $project_path, $parameters)
data/history.md CHANGED
@@ -1,3 +1,9 @@
1
+ ## Version 1.7.0.3 / 2010-06-08
2
+
3
+ * New: ability to add several master files at once
4
+ `wti add file1 file2 file3 …`
5
+ `wti add *.yml`.
6
+
1
7
  ## Version 1.7.0.2 / 2010-05-31
2
8
 
3
9
  * Fix bug with file permissions.
@@ -2,62 +2,22 @@
2
2
  module WebTranslateIt
3
3
  class CommandLine
4
4
  require 'fileutils'
5
-
6
- OPTIONS = <<-OPTION
7
- pull Pull target language file(s) from Web Translate It.
8
- push Push master language file(s) to Web Translate It.
9
- add Create a new master language file to Web Translate It.
10
- autoconf Configure your project to sync with Web Translate It.
11
- stats Fetch and display your project statistics.
12
- server Launch web-based synchronisation console.
13
-
14
- OPTIONAL PARAMETERS:
15
- --------------------
16
- -l --locale The ISO code of a specific locale to pull or push.
17
- -c --config Path to a translation.yml file. If this option
18
- is absent, looks for config/translation.yml.
19
- -h --host Set server host when using `wti server` (default 0.0.0.0).
20
- -p --port Set server port when using `wti server` (default 4000).
21
- --all Respectively download or upload all files.
22
- --force Force wti pull to re-download the language file,
23
- regardless if local version is current.
24
- --merge Force WTI to perform a merge of this file with its database.
25
- --ignore_missing Force WTI to not obsolete missing strings.
26
-
27
- OTHER:
28
- ------
29
- -v --version Show version.
30
- -h --help This page.
31
- OPTION
32
-
33
- def self.run
34
- case ARGV[0]
35
- when 'pull'
36
- pull
37
- when 'push'
38
- push
39
- when 'add'
40
- add
41
- when 'autoconf'
5
+ attr_accessor :configuration, :options, :parameters
6
+
7
+ def initialize(command, options, path, parameters)
8
+ self.options = options
9
+ self.parameters = parameters
10
+ if command == 'autoconf'
42
11
  autoconf
43
- when 'stats'
44
- stats
45
- when 'server'
46
- server
47
- when '-v', '--version'
48
- show_version
49
- when '-h', '--help'
50
- show_options
51
- else
52
- puts "Command not found"
53
- show_options
12
+ exit
54
13
  end
14
+ self.configuration = WebTranslateIt::Configuration.new(path, options.config)
15
+ self.send(command)
55
16
  end
56
17
 
57
- def self.pull
18
+ def pull
58
19
  STDOUT.sync = true
59
- configuration = fetch_configuration
60
- fetch_locales_to_pull(configuration).each do |locale|
20
+ fetch_locales_to_pull.each do |locale|
61
21
  configuration.files.find_all{ |file| file.locale == locale }.each do |file|
62
22
  print "Pulling #{file.file_path}… "
63
23
  puts file.fetch(ARGV.index('--force'))
@@ -65,9 +25,8 @@ OPTION
65
25
  end
66
26
  end
67
27
 
68
- def self.push
28
+ def push
69
29
  STDOUT.sync = true
70
- configuration = fetch_configuration
71
30
  fetch_locales_to_push(configuration).each do |locale|
72
31
  merge = !(ARGV.index('--merge')).nil?
73
32
  ignore_missing = !(ARGV.index('--ignore_missing')).nil?
@@ -78,16 +37,21 @@ OPTION
78
37
  end
79
38
  end
80
39
 
81
- def self.add
40
+ def add
82
41
  STDOUT.sync = true
83
- configuration = fetch_configuration
84
- file_path = fetch_file_to_add(configuration)
85
- file = TranslationFile.new(nil, file_path, nil, configuration.api_key)
86
- print "Creating #{file.file_path}… "
87
- puts file.create
42
+ if parameters.nil?
43
+ puts "Usage: wti add file1 file2"
44
+ exit
45
+ end
46
+ parameters.each do |param|
47
+ file = TranslationFile.new(nil, param, nil, configuration.api_key)
48
+ print "Creating #{file.file_path}… "
49
+ puts file.create
50
+ end
51
+ puts "Master file added! Use `wti push --all` to send your existing translations."
88
52
  end
89
53
 
90
- def self.autoconf
54
+ def autoconf
91
55
  puts "We will attempt to configure your project automagically"
92
56
  api_key = Util.ask("Please enter your project API Key")
93
57
  path = Util.ask("Where should we create the configuration file?", 'config/translation.yml')
@@ -117,8 +81,7 @@ OPTION
117
81
  end
118
82
  end
119
83
 
120
- def self.stats
121
- configuration = fetch_configuration
84
+ def stats
122
85
  stats = YAML.load(Project.fetch_stats(configuration.api_key))
123
86
  stale = false
124
87
  stats.each do |locale, values|
@@ -128,84 +91,47 @@ OPTION
128
91
  stale = true if values['stale']
129
92
  end
130
93
  if stale
131
- CommandLine.stats if Util.ask_yes_no("Some statistics displayed above are stale. Would you like to refresh?", true)
94
+ self.stats if Util.ask_yes_no("Some statistics displayed above are stale. Would you like to refresh?", true)
132
95
  end
133
96
  end
134
97
 
135
- def self.server
136
- host_port = fetch_server_host_and_port
137
- WebTranslateIt::Server.start(host_port[0], host_port[1])
138
- end
139
-
140
- def self.show_options
141
- puts ""
142
- puts "Web Translate It Help:"
143
- puts "**********************"
144
- $stdout.puts OPTIONS
145
- end
146
-
147
- def self.show_version
148
- puts ""
149
- puts "Web Translate It #{WebTranslateIt::Util.version}"
150
- end
151
-
152
- def self.fetch_configuration
153
- if (index = ARGV.index('-c') || ARGV.index('--config')).nil?
154
- configuration = WebTranslateIt::Configuration.new('.')
155
- else
156
- configuration = WebTranslateIt::Configuration.new('.', ARGV[index+1])
157
- end
158
- return configuration
98
+ def server
99
+ WebTranslateIt::Server.start(options.host, options.port)
159
100
  end
160
-
161
- def self.fetch_server_host_and_port
162
- if (index = ARGV.index('-h') || ARGV.index('--host')).nil?
163
- host = "0.0.0.0"
164
- else
165
- host = ARGV[index+1]
166
- end
167
- if (index = ARGV.index('-p') || ARGV.index('--port')).nil?
168
- port = "4000"
101
+
102
+ def fetch_locales_to_pull
103
+ if options.locale
104
+ locales = [options.locale]
169
105
  else
170
- port = ARGV[index+1]
171
- end
172
- return [host,port]
173
- end
174
-
175
- def self.fetch_locales_to_pull(configuration)
176
- if (index = ARGV.index('-l') || ARGV.index('--locale')).nil?
177
106
  locales = configuration.target_locales
178
107
  configuration.ignore_locales.each{ |locale_to_delete| locales.delete(locale_to_delete) }
179
- else
180
- locales = [ARGV[index+1]]
181
108
  end
182
- locales.push(configuration.source_locale) if ARGV.index('--all')
109
+ locales.push(configuration.source_locale) if options.all
183
110
  return locales.uniq
184
111
  end
185
-
186
- def self.fetch_file_to_add(configuration)
187
- index = ARGV.index('add')
188
- file_path = ARGV[index+1].strip
189
- return file_path
190
- end
191
-
192
- def self.fetch_locales_to_push(configuration)
193
- if (index = ARGV.index('-l') || ARGV.index('--locale')).nil?
194
- locales = [configuration.source_locale]
112
+
113
+ def fetch_locales_to_push(configuration)
114
+ if options.locale
115
+ locales = [options.locale]
195
116
  else
196
- locales = [ARGV[index+1]]
117
+ locales = [configuration.source_locale]
197
118
  end
198
- locales += configuration.target_locales if ARGV.index('--all')
119
+ locales += configuration.target_locales if options.all
199
120
  return locales.uniq
200
121
  end
201
122
 
202
- def self.generate_configuration(api_key, project_info)
123
+ def generate_configuration(api_key, project_info)
203
124
  file = <<-FILE
204
125
  api_key: #{api_key}
205
126
 
206
127
  # Optional: locales not to sync with Web Translate It.
207
128
  # eg. [:en, :fr] or just 'en'
208
129
  # ignore_locales: '#{project_info["source_locale"]["code"]}'
130
+
131
+ # Optional, only used by wti server
132
+ # before_pull: "echo 'some unix command'" # Command executed before pulling files
133
+ # after_pull: "touch tmp/restart.txt" # Command executed after pulling files
134
+
209
135
  FILE
210
136
  return file
211
137
  end
@@ -32,7 +32,7 @@ module WebTranslateIt
32
32
 
33
33
  post '/pull' do
34
34
  `#{config.before_pull}` if config.before_pull
35
- WebTranslateIt::CommandLine.pull
35
+ `wti pull`
36
36
  `#{config.after_pull}` if config.after_pull
37
37
  redirect "/"
38
38
  end
@@ -45,6 +45,5 @@ module WebTranslateIt
45
45
  def self.start(host, port)
46
46
  WebTranslateIt::Server.run! :host => host, :port => port
47
47
  end
48
-
49
48
  end
50
49
  end
@@ -52,7 +52,7 @@
52
52
  </div>
53
53
  <div class="contact">
54
54
  <p>
55
- <code>wti</code> v.<%= WebTranslateIt::Util.version %><br/>
55
+ wti v.<%= WebTranslateIt::Util.version %><br/>
56
56
  Built with <a href="http://sinatrarb.com/">Sinatra</a>
57
57
  </p>
58
58
  </div>
data/version.yml CHANGED
@@ -2,4 +2,4 @@
2
2
  :major: 1
3
3
  :minor: 7
4
4
  :tiny: 0
5
- :patch: 2
5
+ :patch: 3
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: 99
4
+ hash: 97
5
5
  prerelease: false
6
6
  segments:
7
7
  - 1
8
8
  - 7
9
9
  - 0
10
- - 2
11
- version: 1.7.0.2
10
+ - 3
11
+ version: 1.7.0.3
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: 2010-05-31 00:00:00 +02:00
19
+ date: 2010-06-08 00:00:00 +02:00
20
20
  default_executable: wti
21
21
  dependencies:
22
22
  - !ruby/object:Gem::Dependency
@@ -35,9 +35,25 @@ dependencies:
35
35
  type: :runtime
36
36
  version_requirements: *id001
37
37
  - !ruby/object:Gem::Dependency
38
- name: sinatra
38
+ name: choice
39
39
  prerelease: false
40
40
  requirement: &id002 !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ~>
44
+ - !ruby/object:Gem::Version
45
+ hash: 19
46
+ segments:
47
+ - 0
48
+ - 1
49
+ - 4
50
+ version: 0.1.4
51
+ type: :runtime
52
+ version_requirements: *id002
53
+ - !ruby/object:Gem::Dependency
54
+ name: sinatra
55
+ prerelease: false
56
+ requirement: &id003 !ruby/object:Gem::Requirement
41
57
  none: false
42
58
  requirements:
43
59
  - - ~>
@@ -48,11 +64,11 @@ dependencies:
48
64
  - 0
49
65
  version: "1.0"
50
66
  type: :runtime
51
- version_requirements: *id002
67
+ version_requirements: *id003
52
68
  - !ruby/object:Gem::Dependency
53
69
  name: rspec
54
70
  prerelease: false
55
- requirement: &id003 !ruby/object:Gem::Requirement
71
+ requirement: &id004 !ruby/object:Gem::Requirement
56
72
  none: false
57
73
  requirements:
58
74
  - - ">="
@@ -64,7 +80,7 @@ dependencies:
64
80
  - 9
65
81
  version: 1.2.9
66
82
  type: :development
67
- version_requirements: *id003
83
+ version_requirements: *id004
68
84
  description: An ruby executable, a sinatra app and a handful of rake tasks to sync your translations between your app and webtranslateit.com.
69
85
  email: edouard@atelierconvivialite.com
70
86
  executables:
@@ -79,7 +95,6 @@ files:
79
95
  - MIT-LICENSE
80
96
  - README.md
81
97
  - version.yml
82
- - examples/en.yml
83
98
  - examples/locale.rb
84
99
  - examples/translation.yml
85
100
  - lib/web_translate_it/auto_fetch.rb
data/examples/en.yml DELETED
@@ -1,38 +0,0 @@
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"