web_translate_it 2.5.3 → 2.6.1
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.
- checksums.yaml +4 -4
- data/bin/wti +107 -107
- data/generators/webtranslateit/lib/insert_commands.rb +6 -8
- data/generators/webtranslateit/webtranslateit_generator.rb +6 -6
- data/history.md +22 -7
- data/lib/web_translate_it/auto_fetch.rb +2 -4
- data/lib/web_translate_it/command_line.rb +264 -230
- data/lib/web_translate_it/configuration.rb +32 -29
- data/lib/web_translate_it/connection.rb +22 -34
- data/lib/web_translate_it/project.rb +22 -25
- data/lib/web_translate_it/string.rb +85 -84
- data/lib/web_translate_it/term.rb +65 -65
- data/lib/web_translate_it/term_translation.rb +34 -36
- data/lib/web_translate_it/translation.rb +25 -32
- data/lib/web_translate_it/translation_file.rb +109 -106
- data/lib/web_translate_it/util/array_util.rb +8 -8
- data/lib/web_translate_it/util/hash_util.rb +5 -5
- data/lib/web_translate_it/util/string_util.rb +5 -8
- data/lib/web_translate_it/util.rb +51 -54
- data/lib/web_translate_it.rb +7 -7
- data/readme.md +13 -9
- data/spec/spec_helper.rb +2 -3
- data/spec/web_translate_it/auto_fetch_spec.rb +1 -2
- data/spec/web_translate_it/string_spec.rb +61 -62
- data/spec/web_translate_it/term_spec.rb +40 -41
- metadata +47 -12
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 48cb64ddfb593274e4eefbca5fde69d8ee35a1fc3c7d1776ef0fc094a64d7db5
|
4
|
+
data.tar.gz: 684e5a256509281d8d2913c4c14aa5d6c9757ef0cce6c9edb00f8d5f84bb90df
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cb75b3f71b20995afb60038a39ce148d92d9b2abd15074a076e9abe14a04d4f0d171e89d75ce864272fa4d6d1ddce62ac5359dcdbf492bc9b10f8931247665ca
|
7
|
+
data.tar.gz: 28cbdd2751c994a285d71d3eee33141b2d0011a79e469375fc28d05da45d775a9e8d31e8b7de3b60b84043e18a0e603b4bfd493cc49e73da54774f1d8cc5a4bd
|
data/bin/wti
CHANGED
@@ -5,28 +5,28 @@ $PROGRAM_NAME = 'wti'
|
|
5
5
|
require 'optimist'
|
6
6
|
require 'web_translate_it'
|
7
7
|
|
8
|
-
show_commands =
|
9
|
-
Usage: wti <command> [options]+ <filename>
|
8
|
+
show_commands = <<~COMMANDS
|
9
|
+
Usage: wti <command> [options]+ <filename>
|
10
10
|
|
11
|
-
The most commonly used wti commands are:
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
11
|
+
The most commonly used wti commands are:
|
12
|
+
pull Pull target language file(s)
|
13
|
+
push Push master language file(s)
|
14
|
+
match Display matching of local files with File Manager
|
15
|
+
add Create and push a new master language file
|
16
|
+
rm Delete a master language file from a project
|
17
|
+
mv Moves a file both locally and from a project
|
18
|
+
addlocale Add a new locale to the project
|
19
|
+
rmlocale Delete a locale from a project
|
20
|
+
status Fetch and display project statistics
|
21
|
+
init Configure your project to sync
|
22
22
|
|
23
|
-
See `wti <command> --help` for more information on a specific command.
|
23
|
+
See `wti <command> --help` for more information on a specific command.
|
24
24
|
|
25
|
-
[options] are:
|
26
|
-
|
25
|
+
[options] are:
|
26
|
+
COMMANDS
|
27
27
|
|
28
|
-
SUB_COMMANDS = %w
|
29
|
-
global_options = Optimist
|
28
|
+
SUB_COMMANDS = %w[pull push match add rm mv addlocale rmlocale status st init].freeze
|
29
|
+
global_options = Optimist.options do
|
30
30
|
stop_on SUB_COMMANDS
|
31
31
|
banner show_commands
|
32
32
|
version "wti version #{WebTranslateIt::Util.version}"
|
@@ -34,98 +34,98 @@ end
|
|
34
34
|
|
35
35
|
command = ARGV.shift # get the subcommand
|
36
36
|
command_options = case command
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
wti pull [filename] - Pull target language file(s)
|
41
|
-
[options] are:
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
wti push [filename] - Push master language file(s)
|
53
|
-
[options] are:
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
37
|
+
when 'pull'
|
38
|
+
Optimist.options do
|
39
|
+
banner <<~BANNER
|
40
|
+
wti pull [filename] - Pull target language file(s)
|
41
|
+
[options] are:
|
42
|
+
BANNER
|
43
|
+
opt :locale, 'ISO code of locale(s) to pull, space-separated', type: :string
|
44
|
+
opt :all, 'Pull all files'
|
45
|
+
opt :force, 'Force pull (bypass conditional requests to WTI)'
|
46
|
+
opt :config, 'Path to a configuration file', short: '-c', default: '.wti'
|
47
|
+
opt :debug, 'Display debug information'
|
48
|
+
end
|
49
|
+
when 'push'
|
50
|
+
Optimist.options do
|
51
|
+
banner <<~BANNER
|
52
|
+
wti push [filename] - Push master language file(s)
|
53
|
+
[options] are:
|
54
|
+
BANNER
|
55
|
+
opt :locale, 'ISO code of locale(s) to push, space-separated', type: :string
|
56
|
+
opt :target, 'Upload all target files'
|
57
|
+
opt :force, 'Force push (bypass conditional requests to WTI)'
|
58
|
+
opt :low_priority, 'WTI will process this file with a low priority'
|
59
|
+
opt :merge, 'Force WTI to merge this file'
|
60
|
+
opt :ignore_missing, 'Force WTI to not obsolete missing strings'
|
61
|
+
opt :minor, 'Minor Changes. When pushing a master file, prevents target translations to be flagged as `to_verify`.'
|
62
|
+
opt :label, 'Apply a label to the changes', type: :string
|
63
|
+
opt :config, 'Path to a configuration file', short: '-c', default: '.wti'
|
64
|
+
opt :all, 'DEPRECATED -- See `wti push --target` instead'
|
65
|
+
opt :debug, 'Display debug information'
|
66
|
+
end
|
67
|
+
when 'add'
|
68
|
+
Optimist.options do
|
69
|
+
banner 'wti add filename - Create and push a new master language file'
|
70
|
+
opt :low_priority, 'WTI will process this file with a low priority'
|
71
|
+
opt :config, 'Path to a configuration file', short: '-c', default: '.wti'
|
72
|
+
opt :debug, 'Display debug information'
|
73
|
+
end
|
74
|
+
when 'rm'
|
75
|
+
Optimist.options do
|
76
|
+
banner 'wti rm filename - Delete a master language file'
|
77
|
+
opt :config, 'Path to a configuration file', short: '-c', default: '.wti'
|
78
|
+
opt :debug, 'Display debug information'
|
79
|
+
end
|
80
|
+
when 'mv'
|
81
|
+
Optimist.options do
|
82
|
+
banner 'wti mv filename - Moves a master language file and its target files'
|
83
|
+
opt :config, 'Path to a configuration file', short: '-c', default: '.wti'
|
84
|
+
opt :debug, 'Display debug information'
|
85
|
+
end
|
86
|
+
when 'addlocale'
|
87
|
+
Optimist.options do
|
88
|
+
banner 'wti addlocale localename - Add a new locale to the project'
|
89
|
+
opt :config, 'Path to a configuration file', short: '-c', default: '.wti'
|
90
|
+
opt :debug, 'Display debug information'
|
91
|
+
end
|
92
|
+
when 'rmlocale'
|
93
|
+
Optimist.options do
|
94
|
+
banner 'wti rmlocale localename Delete a locale from the project'
|
95
|
+
opt :config, 'Path to a configuration file', short: '-c', default: '.wti'
|
96
|
+
opt :debug, 'Display debug information'
|
97
|
+
end
|
98
|
+
when 'status'
|
99
|
+
Optimist.options do
|
100
|
+
banner "wti status - Fetch and display project statistics.\nReturns 100 if untranslated segments exist in project\nReturns 101 if unproofread segments exist in project."
|
101
|
+
opt :config, 'Path to a configuration file', short: '-c', default: '.wti'
|
102
|
+
opt :debug, 'Display debug information'
|
103
|
+
end
|
104
|
+
when 'init'
|
105
|
+
Optimist.options do
|
106
|
+
banner 'wti init [api_token] - Configure your project to sync'
|
107
|
+
opt :config, 'Path to a configuration file', short: '-c', default: '.wti'
|
108
|
+
opt :debug, 'Display debug information'
|
109
|
+
end
|
110
|
+
when 'match'
|
111
|
+
Optimist.options do
|
112
|
+
banner 'wti match - Display matching of local files with File Manager'
|
113
|
+
opt :config, 'Path to a configuration file', short: '-c', default: '.wti'
|
114
|
+
opt :debug, 'Display debug information'
|
115
|
+
end
|
116
|
+
else
|
117
|
+
if command.nil?
|
118
|
+
puts show_commands
|
119
|
+
exit
|
120
|
+
else
|
121
|
+
Optimist.die "Unknown subcommand #{command.inspect}"
|
122
|
+
end
|
123
|
+
end
|
124
124
|
|
125
125
|
begin
|
126
126
|
WebTranslateIt::Connection.turn_debug_on if command_options.debug
|
127
|
-
WebTranslateIt::CommandLine.new(command, command_options, global_options, ARGV, File.expand_path(
|
128
|
-
rescue Interrupt
|
127
|
+
WebTranslateIt::CommandLine.new(command, command_options, global_options, ARGV, File.expand_path('.'))
|
128
|
+
rescue Interrupt
|
129
129
|
puts StringUtil.failure("\nQuitting...")
|
130
130
|
exit 1
|
131
131
|
end
|
@@ -9,11 +9,11 @@ end
|
|
9
9
|
Rails::Generator::Commands::Create.class_eval do
|
10
10
|
def append_to(file, line)
|
11
11
|
logger.insert "#{line} appended to #{file}"
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
12
|
+
return if options[:pretend] || file_contains?(file, line)
|
13
|
+
|
14
|
+
File.open(file, 'a') do |f|
|
15
|
+
f.puts
|
16
|
+
f.puts line
|
17
17
|
end
|
18
18
|
end
|
19
19
|
end
|
@@ -21,9 +21,7 @@ end
|
|
21
21
|
Rails::Generator::Commands::Destroy.class_eval do
|
22
22
|
def append_to(file, line)
|
23
23
|
logger.remove "#{line} removed from #{file}"
|
24
|
-
unless options[:pretend]
|
25
|
-
gsub_file file, "\n#{line}", ''
|
26
|
-
end
|
24
|
+
gsub_file file, "\n#{line}", '' unless options[:pretend]
|
27
25
|
end
|
28
26
|
end
|
29
27
|
|
@@ -1,26 +1,26 @@
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__)
|
1
|
+
require File.expand_path("#{File.dirname(__FILE__)}/lib/insert_commands.rb")
|
2
2
|
|
3
3
|
class WebtranslateitGenerator < Rails::Generator::Base
|
4
4
|
def add_options!(opt)
|
5
|
-
opt.on('-k', '--api-key=key', String,
|
5
|
+
opt.on('-k', '--api-key=key', String, 'Your Web Translate It API key') { |v| options[:api_key] = v }
|
6
6
|
end
|
7
7
|
|
8
|
-
def manifest
|
8
|
+
def manifest # rubocop:todo Metrics/AbcSize, Metrics/MethodLength
|
9
9
|
if !api_key_configured? && !options[:api_key]
|
10
|
-
puts
|
10
|
+
puts 'You must pass --api-key or create config/translations.yml'
|
11
11
|
exit
|
12
12
|
end
|
13
13
|
record do |m|
|
14
14
|
if options[:api_key]
|
15
15
|
project_details = YAML.load WebTranslateIt::Project.fetch_info(options[:api_key])
|
16
16
|
m.template '.wti', '.wti',
|
17
|
-
|
17
|
+
assigns: { api_key: options[:api_key], project: project_details['project'] }
|
18
18
|
m.append_to 'Rakefile', "require 'web_translate_it' rescue LoadError"
|
19
19
|
end
|
20
20
|
end
|
21
21
|
end
|
22
22
|
|
23
23
|
def api_key_configured?
|
24
|
-
File.
|
24
|
+
File.exist?('config/translations.yml')
|
25
25
|
end
|
26
26
|
end
|
data/history.md
CHANGED
@@ -1,3 +1,18 @@
|
|
1
|
+
## Version 2.6.1 / 2022-03-09
|
2
|
+
|
3
|
+
* Display error message for `before_pull`, `after_pull`, `before_push`, `after_push` hooks.
|
4
|
+
* Remove `silence_errors` option in configuration file. If SSL isn’t properly configured, it needs to be fixed by updating your cert chain.
|
5
|
+
|
6
|
+
## Version 2.6.0 / 2022-03-08
|
7
|
+
|
8
|
+
* Code cleaning using Rubocop.
|
9
|
+
* Add ability to ignore files from pulls with a setting in the `.wti` file. Example:
|
10
|
+
`ignore_files: ['**/fr.yml', 'config/locales/js/*.yml', 'config/locales/app/fr.yml']`
|
11
|
+
|
12
|
+
## Version 2.5.4 / 2022-03-08
|
13
|
+
|
14
|
+
* Better support for `before_pull`, `after_pull`, `before_push`, `after_push` hooks. They now display the command output, and write an error message if the exit status of the command was not successful.
|
15
|
+
|
1
16
|
## Version 2.5.3 / 2022-02-04
|
2
17
|
|
3
18
|
* Properly fix ruby compatibility issues.
|
@@ -15,7 +30,7 @@
|
|
15
30
|
* Display files that are being updated on WebTranslateIt but are not ready to be downloaded by a `*`.
|
16
31
|
|
17
32
|
``` bash
|
18
|
-
~/Desktop/test% wti pull
|
33
|
+
~/Desktop/test% wti pull
|
19
34
|
# Pulling files on test 3
|
20
35
|
*cs-CZ.de.yml | 65a7fc8..65a7fc8 Skipped
|
21
36
|
en.yml | ffd8096..ffd8096 Skipped
|
@@ -242,7 +257,7 @@
|
|
242
257
|
|
243
258
|
## Version 2.0.0.rc1 / 2012-04-16 (yanked)
|
244
259
|
|
245
|
-
**Important**: This release candidate introduce breaking changes in the String, Translation, Term and TermTranslation APIs. See [Extras](https://github.com/AtelierConvivialite/webtranslateit/wiki/Extras) if you use the String, Translation, Term and TermTranslation APIs to programmatically manage strings, translations and terms.
|
260
|
+
**Important**: This release candidate introduce breaking changes in the String, Translation, Term and TermTranslation APIs. See [Extras](https://github.com/AtelierConvivialite/webtranslateit/wiki/Extras) if you use the String, Translation, Term and TermTranslation APIs to programmatically manage strings, translations and terms.
|
246
261
|
|
247
262
|
* Remove undeclared dependency on ActiveSupport. ActiveSupport was required to use the `WebTranslateIt::String`, `Translation`, `Term` and `TermTranslation` classes. #84
|
248
263
|
* Refactor `WebTranslateIt::String` and `WebTranslateIt::Translation` classes and add specs. #85
|
@@ -290,9 +305,9 @@
|
|
290
305
|
* Fix `wti status` command.
|
291
306
|
* Improvement: truncate `wti pull` performance statistics (`Pulled 10 files in 0.7 seconds at 13.4 files/sec`).
|
292
307
|
* Fix: Configuration file lookup improvements. Configuration files can now be located in another directory, and `wti` commands don’t have to be executed in the root directory. It is now possible to execute:
|
293
|
-
|
308
|
+
|
294
309
|
```
|
295
|
-
wti pull
|
310
|
+
wti pull
|
296
311
|
wti pull -c /Users/edouard/code/test/.wti
|
297
312
|
wti pull -c ../.wti
|
298
313
|
wti pull -c ~/code/.wti
|
@@ -307,7 +322,7 @@
|
|
307
322
|
|
308
323
|
## Version 1.9.0 / 2011-11-23
|
309
324
|
|
310
|
-
* Deprecate `wti server`. This feature was introducing a hard dependency on Sinatra, which is not desirable when embedding `web_translate_it` on a Rails application. `wti server` now lives in a separate gem, `web_translate_it_server`, which depends on the `web_translate_it` gem. To keep using `wti server`, execute: `gem install web_translate_it_server` and run: `wti-server`.
|
325
|
+
* Deprecate `wti server`. This feature was introducing a hard dependency on Sinatra, which is not desirable when embedding `web_translate_it` on a Rails application. `wti server` now lives in a separate gem, `web_translate_it_server`, which depends on the `web_translate_it` gem. To keep using `wti server`, execute: `gem install web_translate_it_server` and run: `wti-server`.
|
311
326
|
|
312
327
|
## Version 1.8.4 / 2011-11-14
|
313
328
|
|
@@ -344,7 +359,7 @@
|
|
344
359
|
## Version 1.8.2.0 / 2011-09-12
|
345
360
|
|
346
361
|
* `wti pull` downloads files in parallel, using up to 20 threads.
|
347
|
-
This makes syncing much faster for projects containing many files (up to 65 files/sec).
|
362
|
+
This makes syncing much faster for projects containing many files (up to 65 files/sec).
|
348
363
|
* Default configuration file was renamed `.wti`. #67.
|
349
364
|
The upgrade process should be seamless. Config file will be renamed if a `config/translation.yml` file is detected.
|
350
365
|
|
@@ -593,7 +608,7 @@ Warning, some deprecations in this version.
|
|
593
608
|
* Add deprecation warning for `wti --upload`, `wti -u`. These commands will be deprecated in favour of `wti push`.
|
594
609
|
* Add -c parameter to specify a configuration file at a custom location.
|
595
610
|
* Add -l parameter to specify a specific language file to pull or push (only works with `wti pull` and `wti push`).
|
596
|
-
* Add --force parameter to force Web Translate It to send the language files again, regardless if the current
|
611
|
+
* Add --force parameter to force Web Translate It to send the language files again, regardless if the current
|
597
612
|
language file version is current (this makes `wti pull` very much slower).
|
598
613
|
* Add `wti autoconf` command to automatically configure your project for Web Translate It.
|
599
614
|
|
@@ -1,6 +1,4 @@
|
|
1
|
-
# encoding: utf-8
|
2
1
|
module WebTranslateIt
|
3
|
-
|
4
2
|
# Class to automatically fetch the last translations from Web Translate It
|
5
3
|
# for every page requested.
|
6
4
|
# This can be used as a rack middleware.
|
@@ -19,7 +17,7 @@ module WebTranslateIt
|
|
19
17
|
@app.call(env)
|
20
18
|
end
|
21
19
|
|
22
|
-
|
20
|
+
private
|
23
21
|
|
24
22
|
def update_translations
|
25
23
|
WebTranslateIt.fetch_translations
|
@@ -27,7 +25,7 @@ module WebTranslateIt
|
|
27
25
|
end
|
28
26
|
|
29
27
|
def valid_request?(env)
|
30
|
-
|
28
|
+
env['PATH_INFO'] !~ /\.(js|css|jpeg|jpg|gif|png|woff)$/
|
31
29
|
end
|
32
30
|
end
|
33
31
|
end
|