web_translate_it 2.5.2 → 2.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -2
- 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 +21 -7
- data/lib/web_translate_it/auto_fetch.rb +2 -4
- data/lib/web_translate_it/command_line.rb +265 -228
- data/lib/web_translate_it/configuration.rb +33 -28
- data/lib/web_translate_it/connection.rb +7 -8
- data/lib/web_translate_it/project.rb +16 -20
- data/lib/web_translate_it/string.rb +79 -78
- data/lib/web_translate_it/term.rb +59 -59
- data/lib/web_translate_it/term_translation.rb +32 -34
- data/lib/web_translate_it/translation.rb +24 -31
- data/lib/web_translate_it/translation_file.rb +105 -102
- 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 +47 -50
- data/lib/web_translate_it.rb +5 -7
- data/readme.md +6 -2
- 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 +43 -41
- metadata +47 -12
checksums.yaml
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
---
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fe142160ce726176d6463e38dff4cbabe3c65a2629e537afd070aa9a273e44c2
|
4
|
+
data.tar.gz: 447cc0c48efca6fbf66588f4426c1583f6945f59118593b5d8be5a7c81db40a4
|
2
5
|
SHA512:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 11cc21a06894851d8ead43d573ef69c197e0132f1b38b0c65b27c29541ce5409e0a076147f323f61d1fc1e8f0d89f91050d4011e421e5907e5d7d493a4939806
|
7
|
+
data.tar.gz: 9b8bad87f54a5ff65265b34e71523fbd3bb6aca4f95293d8c59bb970d8bc6de7fae9ea7d2cf3078a0004ffdd4720c03bc0f9ca59a3198390585698a73b6f08bb
|
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,17 @@
|
|
1
|
+
## Version 2.6.0 / 2022-03-08
|
2
|
+
|
3
|
+
* Code cleaning using Rubocop.
|
4
|
+
* Add ability to ignore files from pulls with a setting in the `.wti` file. Example:
|
5
|
+
`ignore_files: ['**/fr.yml', 'config/locales/js/*.yml', 'config/locales/app/fr.yml']`
|
6
|
+
|
7
|
+
## Version 2.5.4 / 2022-03-08
|
8
|
+
|
9
|
+
* 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.
|
10
|
+
|
11
|
+
## Version 2.5.3 / 2022-02-04
|
12
|
+
|
13
|
+
* Properly fix ruby compatibility issues.
|
14
|
+
|
1
15
|
## Version 2.5.2 / 2022-02-02
|
2
16
|
|
3
17
|
* Fix compatibility issues with rubies < 2.6.
|
@@ -11,7 +25,7 @@
|
|
11
25
|
* Display files that are being updated on WebTranslateIt but are not ready to be downloaded by a `*`.
|
12
26
|
|
13
27
|
``` bash
|
14
|
-
~/Desktop/test% wti pull
|
28
|
+
~/Desktop/test% wti pull
|
15
29
|
# Pulling files on test 3
|
16
30
|
*cs-CZ.de.yml | 65a7fc8..65a7fc8 Skipped
|
17
31
|
en.yml | ffd8096..ffd8096 Skipped
|
@@ -238,7 +252,7 @@
|
|
238
252
|
|
239
253
|
## Version 2.0.0.rc1 / 2012-04-16 (yanked)
|
240
254
|
|
241
|
-
**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.
|
255
|
+
**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.
|
242
256
|
|
243
257
|
* Remove undeclared dependency on ActiveSupport. ActiveSupport was required to use the `WebTranslateIt::String`, `Translation`, `Term` and `TermTranslation` classes. #84
|
244
258
|
* Refactor `WebTranslateIt::String` and `WebTranslateIt::Translation` classes and add specs. #85
|
@@ -286,9 +300,9 @@
|
|
286
300
|
* Fix `wti status` command.
|
287
301
|
* Improvement: truncate `wti pull` performance statistics (`Pulled 10 files in 0.7 seconds at 13.4 files/sec`).
|
288
302
|
* 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:
|
289
|
-
|
303
|
+
|
290
304
|
```
|
291
|
-
wti pull
|
305
|
+
wti pull
|
292
306
|
wti pull -c /Users/edouard/code/test/.wti
|
293
307
|
wti pull -c ../.wti
|
294
308
|
wti pull -c ~/code/.wti
|
@@ -303,7 +317,7 @@
|
|
303
317
|
|
304
318
|
## Version 1.9.0 / 2011-11-23
|
305
319
|
|
306
|
-
* 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`.
|
320
|
+
* 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`.
|
307
321
|
|
308
322
|
## Version 1.8.4 / 2011-11-14
|
309
323
|
|
@@ -340,7 +354,7 @@
|
|
340
354
|
## Version 1.8.2.0 / 2011-09-12
|
341
355
|
|
342
356
|
* `wti pull` downloads files in parallel, using up to 20 threads.
|
343
|
-
This makes syncing much faster for projects containing many files (up to 65 files/sec).
|
357
|
+
This makes syncing much faster for projects containing many files (up to 65 files/sec).
|
344
358
|
* Default configuration file was renamed `.wti`. #67.
|
345
359
|
The upgrade process should be seamless. Config file will be renamed if a `config/translation.yml` file is detected.
|
346
360
|
|
@@ -589,7 +603,7 @@ Warning, some deprecations in this version.
|
|
589
603
|
* Add deprecation warning for `wti --upload`, `wti -u`. These commands will be deprecated in favour of `wti push`.
|
590
604
|
* Add -c parameter to specify a configuration file at a custom location.
|
591
605
|
* Add -l parameter to specify a specific language file to pull or push (only works with `wti pull` and `wti push`).
|
592
|
-
* Add --force parameter to force Web Translate It to send the language files again, regardless if the current
|
606
|
+
* Add --force parameter to force Web Translate It to send the language files again, regardless if the current
|
593
607
|
language file version is current (this makes `wti pull` very much slower).
|
594
608
|
* Add `wti autoconf` command to automatically configure your project for Web Translate It.
|
595
609
|
|
@@ -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
|