web_translate_it 1.8.0.1 → 1.8.1.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 CHANGED
@@ -3,33 +3,50 @@
3
3
  require 'trollop'
4
4
  require 'web_translate_it'
5
5
 
6
- SUB_COMMANDS = %w(pull push add addlocale server status st init)
6
+ SUB_COMMANDS = %w(pull push match add addlocale server status st init)
7
7
  global_options = Trollop::options do
8
+ stop_on SUB_COMMANDS
8
9
  banner <<-EOS
9
- wti is a command line tool to sync your local translation files
10
- with the WebTranslateIt.com service.
11
10
 
12
- Usage:
13
- wti <command> [options]+
11
+ Usage: wti <command> [options]+
12
+
13
+ The most commonly used wti commands are:
14
+
15
+ pull Pull target language file(s)
16
+ push Push master language file(s)
17
+ match Display matching of local files with File Manager
18
+ add Create and push a new master language file
19
+ addlocale Add a new locale to the project
20
+ server Start a synchronisation server
21
+ status Fetch and display project statistics
22
+ init Configure your project to sync
23
+
24
+ See `wti <command> --help` for more information on a specific command.
14
25
 
15
- <command> is one of: #{SUB_COMMANDS.join(" ")}
16
- [options] are:
17
- EOS
26
+ [options] are:
27
+ EOS
18
28
  version "Web Translate It v#{WebTranslateIt::Util.version}"
19
29
  opt :config, "Path to a translation.yml file", :short => "-c", :default => "config/translation.yml"
20
- stop_on SUB_COMMANDS
21
30
  end
22
31
 
23
32
  command = ARGV.shift # get the subcommand
24
33
  command_options = case command
25
34
  when "pull"
26
35
  Trollop::options do
36
+ banner <<-EOS
37
+ Pull target language file(s)
38
+ [options] are:
39
+ EOS
27
40
  opt :locale, "ISO code of locale(s) to pull", :type => :string
28
41
  opt :all, "Pull all files"
29
42
  opt :force, "Force pull (bypass conditional requests to WTI)"
30
43
  end
31
44
  when "push"
32
45
  Trollop::options do
46
+ banner <<-EOS
47
+ Push master language file(s)
48
+ [options] are:
49
+ EOS
33
50
  opt :locale, "ISO code of locale(s) to push", :type => :string
34
51
  opt :all, "Upload all files"
35
52
  opt :low_priority, "WTI will process this file with a low priority"
@@ -38,17 +55,33 @@ command_options = case command
38
55
  opt :label, "Apply a label to the changes", :type => :string
39
56
  end
40
57
  when "add"
58
+ Trollop::options { banner "Create and push a new master language file" }
41
59
  when "addlocale"
60
+ Trollop::options { banner "Add a new locale to the project" }
42
61
  when "server"
43
62
  Trollop::options do
63
+ banner <<-EOS
64
+ Start a synchronisation server
65
+ [options] are:
66
+ EOS
44
67
  opt :port, "Run server on a specific port", :default => 4000, :short => "-p"
45
68
  opt :host, "Run server on a specific host", :default => "0.0.0.0", :short => "-h"
46
69
  end
47
70
  when "status"
71
+ Trollop::options { banner "Fetch and display project statistics" }
48
72
  when "st"
49
73
  when "init"
74
+ Trollop::options { banner "Configure your project to sync" }
75
+ when "match"
76
+ Trollop::options { banner "Display matching of local files with File Manager" }
50
77
  else
51
78
  Trollop::die "Unknown subcommand #{command.inspect}"
52
79
  end
53
80
 
54
- WebTranslateIt::CommandLine.new(command, command_options, global_options, ARGV, File.expand_path("."))
81
+ begin
82
+ WebTranslateIt::CommandLine.new(command, command_options, global_options, ARGV, File.expand_path("."))
83
+ rescue Interrupt => e
84
+ puts "\nQuitting...".failure
85
+ exit 1
86
+ end
87
+
data/history.md CHANGED
@@ -1,3 +1,12 @@
1
+ ## Version 1.8.1.0 / 2011-06-08
2
+
3
+ * Upgrade `multipart-post` dependency.
4
+ * Replace `rainbow` dependency by `ansi`, which can also format columns. #55
5
+ * Bug fix: `translation.yml` file wasn’t created on new projects.
6
+ * New: Gracefully quit on interrupt.
7
+ * New command: `wti match`. Displays files matching with the File Manager.
8
+ * Improved help commands.
9
+
1
10
  ## Version 1.8.0.1 / 2011-06-01
2
11
 
3
12
  * Fix: SSL certificate verification wasn’t working on some systems (at least Ubuntu).
@@ -1,5 +1,5 @@
1
1
  # encoding: utf-8
2
- require 'rubygems'
2
+
3
3
  require 'web_translate_it/util'
4
4
  require 'web_translate_it/configuration'
5
5
  require 'web_translate_it/translation_file'
@@ -14,14 +14,11 @@ 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
+ puts "Pulling files ".bold.underline
20
18
  WebTranslateIt::Util.http_connection do |http|
21
19
  fetch_locales_to_pull.each do |locale|
22
20
  configuration.files.find_all{ |file| file.locale == locale }.each do |file|
23
- print " * #{file.file_path}: "
24
- puts file.fetch(http, command_options.force)
21
+ file.fetch(http, command_options.force)
25
22
  end
26
23
  end
27
24
  end
@@ -31,14 +28,11 @@ module WebTranslateIt
31
28
  def push
32
29
  STDOUT.sync = true
33
30
  `#{configuration.before_push}` if configuration.before_push
34
- puts ""
35
- puts " Pushing files ".bright
36
- puts ""
31
+ puts "Pushing files ".bold.underline
37
32
  WebTranslateIt::Util.http_connection do |http|
38
33
  fetch_locales_to_push(configuration).each do |locale|
39
34
  configuration.files.find_all{ |file| file.locale == locale }.each do |file|
40
- print " * #{file.file_path}... "
41
- puts file.upload(http, command_options[:merge], command_options.ignore_missing, command_options.label, command_options.low_priority)
35
+ file.upload(http, command_options[:merge], command_options.ignore_missing, command_options.label, command_options.low_priority)
42
36
  end
43
37
  end
44
38
  end
@@ -55,8 +49,7 @@ module WebTranslateIt
55
49
  WebTranslateIt::Util.http_connection do |http|
56
50
  parameters.each do |param|
57
51
  file = TranslationFile.new(nil, param, nil, configuration.api_key)
58
- print "Creating #{file.file_path}... "
59
- puts file.create(http)
52
+ file.create(http)
60
53
  end
61
54
  end
62
55
  puts "Master file added.".success
@@ -82,30 +75,32 @@ module WebTranslateIt
82
75
  FileUtils.mkpath(path.split('/')[0..path.split('/').size-2].join('/'))
83
76
  project = YAML.load WebTranslateIt::Project.fetch_info(api_key)
84
77
  project_info = project['project']
85
- if !File.writable?(path)
78
+ if File.exists?(path) && !File.writable?(path)
86
79
  puts "Error: #{path} is not writable.".failure
87
80
  exit
88
81
  end
89
82
  File.open(path, 'w'){ |file| file << generate_configuration(api_key, project_info) }
90
- error = false
91
- project_info['project_files'].each do |file|
92
- if file['name'].nil? or file['name'].strip == ''
93
- puts "Project File #{file['id']} doesn’t seem to be set up.".failure
94
- error = true
95
- elsif !File.exists?(file['name'])
96
- puts "Could not find file `#{file['name']}` locally."
97
- error = true
83
+ puts ""
84
+ puts "Done! You can now use `wti` to push and pull your language files."
85
+ puts "Check `wti --help` for help."
86
+ end
87
+
88
+ def match
89
+ puts "Matching local files with File Manager".bold.underline
90
+ puts ""
91
+ configuration.files.find_all{ |mf| mf.locale == configuration.source_locale }.each do |master_file|
92
+ if !File.exists?(master_file.file_path)
93
+ puts master_file.file_path.failure + " (#{master_file.locale})"
98
94
  else
99
- puts "Found #{file['name']}.".success
95
+ puts master_file.file_path.bold + " (#{master_file.locale})"
96
+ end
97
+ configuration.files.find_all{ |f| f.master_id == master_file.id }.each do |file|
98
+ if !File.exists?(file.file_path)
99
+ puts "- #{file.file_path}".failure + " (#{file.locale})"
100
+ else
101
+ puts "- #{file.file_path}" + " (#{file.locale})"
102
+ end
100
103
  end
101
- end
102
- if error
103
- puts "Please check the correct full path is specified in the File Manager"
104
- puts "https://webtranslateit.com/projects/#{project_info['id']}/files"
105
- else
106
- puts ""
107
- puts "Done! You can now use `wti` to push and pull your language files."
108
- puts "Check `wti --help` for help."
109
104
  end
110
105
  end
111
106
 
@@ -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'], project_file['hash_file'])
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'], project_file['master_project_file_id'])
53
53
  end
54
54
  end
55
55
  end
@@ -12,15 +12,16 @@ 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
15
+ attr_accessor :id, :file_path, :locale, :api_key, :updated_at, :remote_checksum, :master_id
16
16
 
17
- def initialize(id, file_path, locale, api_key, updated_at = nil, remote_checksum = "")
17
+ def initialize(id, file_path, locale, api_key, updated_at = nil, remote_checksum = "", master_id = nil)
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
23
  self.remote_checksum = remote_checksum
24
+ self.master_id = master_id
24
25
  end
25
26
 
26
27
  # Fetch a language file.
@@ -36,16 +37,18 @@ module WebTranslateIt
36
37
  # file.fetch(true) # force to re-download the file, will return the content of the file with a 200 OK
37
38
  #
38
39
  def fetch(http_connection, force = false)
39
- print "#{self.local_checksum.to_s.checksumify}...#{self.remote_checksum.to_s.checksumify} "
40
+ display = []
41
+ display.push(self.file_path)
42
+ display.push "#{self.local_checksum.to_s.checksumify}..#{self.remote_checksum.to_s.checksumify}"
40
43
  if !File.exist?(self.file_path) or force or self.remote_checksum != self.local_checksum
41
44
  begin
42
45
  response = http_connection.get(api_url)
43
46
  FileUtils.mkpath(self.file_path.split('/')[0..-2].join('/')) unless File.exist?(self.file_path) or self.file_path.split('/')[0..-2].join('/') == ""
44
47
  begin
45
48
  File.open(self.file_path, 'wb'){ |file| file << response.body } if response.code.to_i == 200 and response.body != ''
46
- Util.handle_response(response)
49
+ display.push Util.handle_response(response)
47
50
  rescue
48
- "/!\\ An error occured: #{$!}".failure
51
+ display.push "An error occured: #{$!}".failure
49
52
  end
50
53
  rescue Timeout::Error
51
54
  puts "Request timeout. Will retry in 5 seconds.".failure
@@ -53,8 +56,9 @@ module WebTranslateIt
53
56
  fetch(http_connection, force)
54
57
  end
55
58
  else
56
- return "Skipped (up to date)".success
59
+ display.push "Skipped".success
57
60
  end
61
+ puts display.to_columns
58
62
  end
59
63
 
60
64
  # Update a language file to Web Translate It by performing a PUT Request.
@@ -69,15 +73,19 @@ module WebTranslateIt
69
73
  # Note that the request might or might not eventually be acted upon, as it might be disallowed when processing
70
74
  # actually takes place. This is due to the fact that language file imports are handled by background processing.
71
75
  def upload(http_connection, merge=false, ignore_missing=false, label=nil, low_priority=false)
76
+ display = []
77
+ display.push(self.file_path)
78
+ display.push "#{self.local_checksum.to_s.checksumify}..#{self.remote_checksum.to_s.checksumify}"
72
79
  if File.exists?(self.file_path)
73
80
  File.open(self.file_path) do |file|
74
81
  begin
75
82
  request = Net::HTTP::Put::Multipart.new(api_url, {"file" => UploadIO.new(file, "text/plain", file.path), "merge" => merge, "ignore_missing" => ignore_missing, "label" => label, "low_priority" => low_priority })
76
- Util.handle_response(http_connection.request(request))
83
+ display.push Util.handle_response(http_connection.request(request))
84
+ puts display.to_columns
77
85
  rescue Timeout::Error
78
86
  puts "Request timeout. Will retry in 5 seconds.".failure
79
87
  sleep(5)
80
- upload(merge, ignore_missing)
88
+ upload(merge, ignore_missing, label, low_priority)
81
89
  end
82
90
  end
83
91
  else
@@ -97,11 +105,15 @@ module WebTranslateIt
97
105
  # actually takes place. This is due to the fact that language file imports are handled by background processing.
98
106
  #
99
107
  def create(http_connection)
108
+ display = []
109
+ display.push file_path
110
+ display.push "#{self.local_checksum.to_s.checksumify}..[ ]"
100
111
  if File.exists?(self.file_path)
101
112
  File.open(self.file_path) do |file|
102
113
  begin
103
114
  request = Net::HTTP::Post::Multipart.new(api_url_for_create, { "name" => self.file_path, "file" => UploadIO.new(file, "text/plain", file.path) })
104
- Util.handle_response(http_connection.request(request))
115
+ display.push Util.handle_response(http_connection.request(request))
116
+ puts display.to_columns
105
117
  rescue Timeout::Error
106
118
  puts "Request timeout. Will retry in 5 seconds.".failure
107
119
  sleep(5)
@@ -45,10 +45,6 @@ module WebTranslateIt
45
45
  ((processed*10)/total).to_f.ceil*10
46
46
  end
47
47
 
48
- def self.welcome_message
49
- puts "Web Translate It v#{version}"
50
- end
51
-
52
48
  def self.handle_response(response, return_response = false)
53
49
  if response.code.to_i >= 400 and response.code.to_i < 500
54
50
  "Error: Can't find project for this API key.".failure
@@ -111,29 +107,6 @@ module WebTranslateIt
111
107
  result
112
108
  end
113
109
 
114
- ##
115
- # Choose from a list of options. +question+ is a prompt displayed above
116
- # the list. +list+ is a list of option strings. Returns the pair
117
- # [option_name, option_index].
118
-
119
- def self.choose_from_list(question, list)
120
- STDOUT.puts question
121
-
122
- list.each_with_index do |item, index|
123
- STDOUT.puts " #{index+1}. #{item}"
124
- end
125
-
126
- STDOUT.print "> "
127
- STDOUT.flush
128
-
129
- result = STDIN.gets
130
-
131
- return nil, nil unless result
132
-
133
- result = result.strip.to_i - 1
134
- return list[result], result
135
- end
136
-
137
110
  ##
138
111
  # Cleans up a locale name
139
112
  # For instance: passing `fr_FR` will return `fr-FR`
@@ -144,27 +117,28 @@ module WebTranslateIt
144
117
  end
145
118
  end
146
119
 
147
- class String
148
- require 'rainbow'
120
+ class Array
121
+ require 'ansi/columns'
149
122
 
150
- ##
151
- # Green foreground for success
123
+ def to_columns
124
+ columns = ANSI::Columns.new(self, :padding => 2)
125
+ columns.to_s(self.size)
126
+ end
127
+ end
128
+
129
+ class String
130
+ require 'ansi/mixin'
131
+ include ANSI::Mixin
152
132
 
153
133
  def success
154
- self.foreground(:green)
134
+ self.green
155
135
  end
156
136
 
157
- ##
158
- # Red foreground for failure
159
-
160
137
  def failure
161
- self.background(:red).foreground(:white)
138
+ self.red.bold
162
139
  end
163
140
 
164
- ##
165
- # trucated, gray foreground for checksums
166
-
167
141
  def checksumify
168
- self[0..6].foreground(:yellow)
142
+ self[0..6].yellow
169
143
  end
170
144
  end
data/readme.md CHANGED
@@ -7,9 +7,9 @@ Web Translate It
7
7
  [Report a bug](http://github.com/AtelierConvivialite/webtranslateit/issues) |
8
8
  [Support](http://help.webtranslateit.com)
9
9
 
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.
10
+ `web_translate_it` is a rubygem providing tools to sync your language files with [Web Translate It](https://webtranslateit.com), a web-based translation software.
11
11
 
12
- ![Web Translate It](http://s3.amazonaws.com:80/edouard.baconfile.com/web_translate_it%2Fwti2.png)
12
+ ![Web Translate It](http://s3.amazonaws.com:80/edouard.baconfile.com/web_translate_it%2Fwti3.png)
13
13
 
14
14
  This gem provides:
15
15
 
@@ -35,7 +35,7 @@ Now that the tool is installed, you’ll have to configure your project:
35
35
 
36
36
  The tool will prompt for:
37
37
 
38
- * your Web Translate It API key (you can find it in your project settings),
38
+ * your Web Translate It API key. You can find it in your project settings ([where are the project settings?](http://help.webtranslateit.com/kb/troubleshooting/where-are-my-project-settings)),
39
39
  * where to save the configuration file (by default in `config/translations.yml`).
40
40
 
41
41
  Usage
@@ -43,34 +43,33 @@ Usage
43
43
 
44
44
  Execute `wti --help` to see the usage:
45
45
 
46
- wti is a command line tool to sync your local translation files
47
- with the WebTranslateIt.com service.
48
-
49
- Usage:
50
- wti <command> [options]+
46
+ Usage: wti <command> [options]+
47
+
48
+ The most commonly used wti commands are:
49
+
50
+ pull Pull target language file(s)
51
+ push Push master language file(s)
52
+ match Display matching of local files with File Manager
53
+ add Create and push a new master language file
54
+ addlocale Add a new locale to the project
55
+ server Start a synchronisation server
56
+ status Fetch and display project statistics
57
+ init Configure your project to sync
58
+
59
+ See `wti <command> --help` for more information on a specific command.
51
60
 
52
- <command> is one of: pull push add addlocale server stats status st autoconf init
53
61
  [options] are:
54
- --config, -c <s>: Path to a translation.yml file (default:
55
- config/translation.yml)
56
- --version, -v: Print version and exit
57
- --help, -h: Show this message
62
+ --config, -c <s>: Path to a translation.yml file (default:
63
+ config/translation.yml)
64
+ --version, -v: Print version and exit
65
+ --help, -h: Show this message
58
66
 
59
- Here’s more explanation about the commands.
60
-
61
- pull Pull target language file(s)
62
- push Push master language file(s)
63
- add Create and push a new master language file
64
- addlocale Add a new locale to the project
65
- server Start a synchronisation server
66
- status Fetch and display project statistics
67
- init Configure your project to sync
68
-
69
- You can get more information by appending `--help` after each command. For instance:
67
+ Append `--help` for each command for more information. For instance:
70
68
 
71
69
  $ wti push --help
72
- Options:
73
- --locale, -l <s>: ISO code of a locale to push
70
+ Push master language file(s)
71
+ [options] are:
72
+ --locale, -l <s>: ISO code of locale(s) to push
74
73
  --all, -a: Upload all files
75
74
  --low-priority, -o: WTI will process this file with a low priority
76
75
  --merge, -m: Force WTI to merge this file
data/spec/spec_helper.rb CHANGED
@@ -1,2 +1,2 @@
1
- require File.dirname(__FILE__) + '/../lib/web_translate_it'
2
- require 'spec'
1
+ require File.expand_path('../../lib/web_translate_it', __FILE__)
2
+ require 'rspec'
@@ -1,4 +1,4 @@
1
- require 'spec/spec_helper'
1
+ require File.expand_path('../spec_helper', __FILE__)
2
2
 
3
3
  module WebTranslateIt
4
4
  class I18n
data/version.yml CHANGED
@@ -1,5 +1,5 @@
1
1
  ---
2
2
  :major: 1
3
3
  :minor: 8
4
- :tiny: 0
5
- :patch: 1
4
+ :tiny: 1
5
+ :patch: 0
metadata CHANGED
@@ -5,9 +5,9 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 8
8
- - 0
9
8
  - 1
10
- version: 1.8.0.1
9
+ - 0
10
+ version: 1.8.1.0
11
11
  platform: ruby
12
12
  authors:
13
13
  - "\xC3\x89douard Bri\xC3\xA8re"
@@ -15,7 +15,7 @@ autorequire:
15
15
  bindir: bin
16
16
  cert_chain: []
17
17
 
18
- date: 2011-06-01 00:00:00 +02:00
18
+ date: 2011-06-08 00:00:00 +02:00
19
19
  default_executable: wti
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
@@ -29,8 +29,8 @@ dependencies:
29
29
  segments:
30
30
  - 1
31
31
  - 1
32
- - 0
33
- version: 1.1.0
32
+ - 2
33
+ version: 1.1.2
34
34
  type: :runtime
35
35
  version_requirements: *id001
36
36
  - !ruby/object:Gem::Dependency
@@ -64,7 +64,7 @@ dependencies:
64
64
  type: :runtime
65
65
  version_requirements: *id003
66
66
  - !ruby/object:Gem::Dependency
67
- name: rainbow
67
+ name: ansi
68
68
  prerelease: false
69
69
  requirement: &id004 !ruby/object:Gem::Requirement
70
70
  none: false
@@ -73,9 +73,9 @@ dependencies:
73
73
  - !ruby/object:Gem::Version
74
74
  segments:
75
75
  - 1
76
- - 1
77
- - 1
78
- version: 1.1.1
76
+ - 2
77
+ - 5
78
+ version: 1.2.5
79
79
  type: :runtime
80
80
  version_requirements: *id004
81
81
  - !ruby/object:Gem::Dependency
@@ -87,10 +87,10 @@ dependencies:
87
87
  - - ">="
88
88
  - !ruby/object:Gem::Version
89
89
  segments:
90
- - 1
91
90
  - 2
92
- - 9
93
- version: 1.2.9
91
+ - 6
92
+ - 0
93
+ version: 2.6.0
94
94
  type: :development
95
95
  version_requirements: *id005
96
96
  description: An ruby executable and a handful of tools to sync your translations between your app and webtranslateit.com.
@@ -101,7 +101,7 @@ extensions: []
101
101
 
102
102
  extra_rdoc_files:
103
103
  - history.md
104
- - README.md
104
+ - readme.md
105
105
  files:
106
106
  - history.md
107
107
  - licence
@@ -128,10 +128,8 @@ files:
128
128
  - man/wti.1
129
129
  - man/wti.1.html
130
130
  - man/wti.1.ron
131
- - README.md
132
131
  - spec/examples/config/translation.yml
133
132
  - spec/examples/en.yml
134
- - spec/spec.opts
135
133
  - spec/spec_helper.rb
136
134
  - spec/web_translate_it/configuration_spec.rb
137
135
  - spec/web_translate_it/translation_file_spec.rb
@@ -144,7 +142,7 @@ licenses: []
144
142
  post_install_message:
145
143
  rdoc_options:
146
144
  - --main
147
- - README.md
145
+ - readme.md
148
146
  require_paths:
149
147
  - lib
150
148
  required_ruby_version: !ruby/object:Gem::Requirement
@@ -173,7 +171,6 @@ summary: Sync your translations between your app and Web Translate It
173
171
  test_files:
174
172
  - spec/examples/config/translation.yml
175
173
  - spec/examples/en.yml
176
- - spec/spec.opts
177
174
  - spec/spec_helper.rb
178
175
  - spec/web_translate_it/configuration_spec.rb
179
176
  - spec/web_translate_it/translation_file_spec.rb
data/README.md DELETED
@@ -1,185 +0,0 @@
1
- Web Translate It
2
- ================
3
-
4
- [Homepage](https://webtranslateit.com) |
5
- [RDoc](http://yardoc.org/docs/AtelierConvivialite-webtranslateit) |
6
- [Example app](http://github.com/AtelierConvivialite/rails_example_app) |
7
- [Report a bug](http://github.com/AtelierConvivialite/webtranslateit/issues) |
8
- [Support](http://help.webtranslateit.com)
9
-
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
-
12
- ![Web Translate It](http://s3.amazonaws.com:80/edouard.baconfile.com/web_translate_it%2Fwti2.png)
13
-
14
- This gem provides:
15
-
16
- * a command-line executable `wti`, to sync your files between your computer/server and WebTranslateIt.com,
17
- * a synchronisation server to help your translation team update your language files from a web interface,
18
- * a rack middleware you can use within your Rails app to automatically fetch new translations from Web Translate It.
19
-
20
- Installation
21
- ------------
22
-
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.
24
-
25
- gem install web_translate_it
26
-
27
- At this point you should have the `wti` executable working.
28
-
29
- Configuration
30
- -------------
31
-
32
- Now that the tool is installed, you’ll have to configure your project:
33
-
34
- wti init
35
-
36
- The tool will prompt for:
37
-
38
- * your Web Translate It API key (you can find it in your project settings),
39
- * where to save the configuration file (by default in `config/translations.yml`).
40
-
41
- Usage
42
- -----
43
-
44
- Execute `wti --help` to see the usage:
45
-
46
- wti is a command line tool to sync your local translation files
47
- with the WebTranslateIt.com service.
48
-
49
- Usage:
50
- wti <command> [options]+
51
-
52
- <command> is one of: pull push add addlocale server stats status st autoconf init
53
- [options] are:
54
- --config, -c <s>: Path to a translation.yml file (default:
55
- config/translation.yml)
56
- --version, -v: Print version and exit
57
- --help, -h: Show this message
58
-
59
- Here’s more explanation about the commands.
60
-
61
- pull Pull target language file(s)
62
- push Push master language file(s)
63
- add Create and push a new master language file
64
- addlocale Add a new locale to the project
65
- server Start a synchronisation server
66
- status Fetch and display project statistics
67
- init Configure your project to sync
68
-
69
- You can get more information by appending `--help` after each command. For instance:
70
-
71
- $ wti push --help
72
- Options:
73
- --locale, -l <s>: ISO code of a locale to push
74
- --all, -a: Upload all files
75
- --low-priority, -o: WTI will process this file with a low priority
76
- --merge, -m: Force WTI to merge this file
77
- --ignore-missing, -i: Force WTI to not obsolete missing strings
78
- --label, -b <s>: Apply a label to the changes
79
- --help, -h: Show this message
80
-
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
- ----------------------------------------
163
-
164
- ![Web Translate It](http://s3.amazonaws.com:80/edouard.baconfile.com/web_translate_it%2Fadmin_console2.png)
165
-
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`.
167
-
168
- To get started, go to the directory of the application you want to sync and do:
169
-
170
- wti server
171
-
172
- By default, it starts an application on localhost on the port 4000. You will find the tool on `http://localhost:4000`.
173
-
174
- Should you need to use another host or port, you can use the `-h` and `-p` options. For example: `wti server -p 1234`.
175
-
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:
177
-
178
- before_pull: "echo 'some unix command'"
179
- after_pull: "touch tmp/restart.txt"
180
-
181
- `before_pull` and `after_pull` are respectively executed before and after pulling language files.
182
-
183
- # License
184
-
185
- Copyright (c) 2009-2011 Atelier Convivialité, released under the MIT License.
data/spec/spec.opts DELETED
@@ -1,4 +0,0 @@
1
- --colour
2
- --format progress
3
- --loadby mtime
4
- --reverse