i18n-tasks 0.9.0.rc2 → 0.9.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.
- checksums.yaml +4 -4
- data/README.md +8 -4
- data/bin/i18n-tasks +0 -0
- data/i18n-tasks.gemspec +2 -1
- data/lib/i18n/tasks/scanners/ruby_ast_scanner.rb +3 -8
- data/lib/i18n/tasks/version.rb +1 -1
- metadata +21 -9
- data/lib/i18n/tasks/scanners/slim_temple_scanner.rb +0 -24
- data/lib/i18n/tasks/scanners/temple_scanner.rb +0 -33
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 2d7150a87197f1366f4f451b84ec214d3f39e86b
|
4
|
+
data.tar.gz: 16d164673b493e94bd45395c49caa208fb8c113c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d9d59b0e9cae6e6624a7977717018cc6297ab32b1a381acd7c2215a6d30d4b7eaf896bee0b920fcb13b90df09e993c62951c2e7791cf040a5504778a3502a70
|
7
|
+
data.tar.gz: 9977c0ef0785acb7fe7bf228edbb78b4446bc487e14dd35c2b058f6a03c07404bb9a878ea2e25089e209f56804e5a01d15676899612b0c59f7057141f5692de8
|
data/README.md
CHANGED
@@ -24,7 +24,7 @@ i18n-tasks can be used with any project using the ruby [i18n gem][i18n-gem] (def
|
|
24
24
|
Add i18n-tasks to the Gemfile:
|
25
25
|
|
26
26
|
```ruby
|
27
|
-
gem 'i18n-tasks', '~> 0.9.0
|
27
|
+
gem 'i18n-tasks', '~> 0.9.0'
|
28
28
|
```
|
29
29
|
|
30
30
|
Copy the default [configuration file](#configuration):
|
@@ -176,7 +176,7 @@ all the dynamic parts of the key will be considered used, e.g. `cats.tenderlove.
|
|
176
176
|
## Configuration
|
177
177
|
|
178
178
|
Configuration is read from `config/i18n-tasks.yml` or `config/i18n-tasks.yml.erb`.
|
179
|
-
Inspect configuration with `i18n-tasks config`.
|
179
|
+
Inspect the configuration with `i18n-tasks config`.
|
180
180
|
|
181
181
|
Install the [default config file][config] with:
|
182
182
|
|
@@ -198,7 +198,8 @@ The default data adapter supports YAML and JSON files.
|
|
198
198
|
#### Multiple locale files
|
199
199
|
|
200
200
|
i18n-tasks can manage multiple translation files and read translations from other gems.
|
201
|
-
To find out more the `data` options in the [config][config].
|
201
|
+
To find out more see the `data` options in the [config][config].
|
202
|
+
NB: By default, only `%{locale}.yml` files are read, not `namespace.%{locale}.yml`. Make sure to check the config.
|
202
203
|
|
203
204
|
For writing to locale files i18n-tasks provides 2 options.
|
204
205
|
|
@@ -251,8 +252,11 @@ If you have implemented a custom adapter please share it on [the wiki][wiki].
|
|
251
252
|
|
252
253
|
### Usage search
|
253
254
|
|
255
|
+
i18n-tasks uses an AST scanner for `.rb` files, and a regexp scanner for all other files.
|
256
|
+
New scanners can be added easily: please refer to [this example](https://github.com/glebm/i18n-tasks/wiki/A-custom-scanner-example).
|
257
|
+
|
254
258
|
See the `search` section in the [config file][config] for all available configuration options.
|
255
|
-
|
259
|
+
NB: By default, only the `app/` directory is searched.
|
256
260
|
|
257
261
|
### Fine-tuning
|
258
262
|
|
data/bin/i18n-tasks
CHANGED
File without changes
|
data/i18n-tasks.gemspec
CHANGED
@@ -33,11 +33,12 @@ TEXT
|
|
33
33
|
s.require_paths = ['lib']
|
34
34
|
|
35
35
|
s.add_dependency 'activesupport', '>= 4.0.2'
|
36
|
+
s.add_dependency 'ast', '>= 2.1.0'
|
36
37
|
s.add_dependency 'easy_translate', '>= 0.5.0'
|
37
38
|
s.add_dependency 'erubis'
|
38
39
|
s.add_dependency 'highline', '>= 1.7.3'
|
39
40
|
s.add_dependency 'i18n'
|
40
|
-
s.add_dependency 'parser', '>= 2.2.
|
41
|
+
s.add_dependency 'parser', '>= 2.2.3.0'
|
41
42
|
s.add_dependency 'term-ansicolor', '>= 1.3.2'
|
42
43
|
s.add_dependency 'terminal-table', '>= 1.5.1'
|
43
44
|
s.add_development_dependency 'axlsx', '~> 2.0'
|
@@ -7,10 +7,11 @@ module I18n::Tasks::Scanners
|
|
7
7
|
# Scan for I18n.translate calls using whitequark/parser
|
8
8
|
class RubyAstScanner < FileScanner
|
9
9
|
include RelativeKeys
|
10
|
+
include AST::Sexp
|
10
11
|
|
11
12
|
MAGIC_COMMENT_PREFIX = /\A.\s*i18n-tasks-use\s+/.freeze
|
12
13
|
|
13
|
-
def initialize(messages: %i(t translate), receivers: [nil,
|
14
|
+
def initialize(messages: %i(t translate), receivers: [nil, s(:const, nil, :I18n)], **args)
|
14
15
|
super(args)
|
15
16
|
@parser = ::Parser::CurrentRuby.new
|
16
17
|
@magic_comment_parser = ::Parser::CurrentRuby.new
|
@@ -39,7 +40,7 @@ module I18n::Tasks::Scanners
|
|
39
40
|
@parser.parse(make_buffer(path, comment.text.sub(MAGIC_COMMENT_PREFIX, '').split(/\s+(?=t)/).join('; ')))
|
40
41
|
) do |send_node, _method_name|
|
41
42
|
# method_name is not available at this stage
|
42
|
-
send_node_to_key_occurrence(send_node, nil, location: associated_node || comment)
|
43
|
+
send_node_to_key_occurrence(send_node, nil, location: associated_node || comment.location)
|
43
44
|
end
|
44
45
|
end
|
45
46
|
rescue Exception => e
|
@@ -183,11 +184,5 @@ module I18n::Tasks::Scanners
|
|
183
184
|
buffer.raw_source = contents
|
184
185
|
}
|
185
186
|
end
|
186
|
-
|
187
|
-
# @param const [Symbol]
|
188
|
-
# @return [AST::Node]
|
189
|
-
def self.const_node(const)
|
190
|
-
AST::Node.new(:const, [nil, const])
|
191
|
-
end
|
192
187
|
end
|
193
188
|
end
|
data/lib/i18n/tasks/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-tasks
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- glebm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-
|
11
|
+
date: 2015-10-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: 4.0.2
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: ast
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 2.1.0
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 2.1.0
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: easy_translate
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -86,14 +100,14 @@ dependencies:
|
|
86
100
|
requirements:
|
87
101
|
- - ">="
|
88
102
|
- !ruby/object:Gem::Version
|
89
|
-
version: 2.2.
|
103
|
+
version: 2.2.3.0
|
90
104
|
type: :runtime
|
91
105
|
prerelease: false
|
92
106
|
version_requirements: !ruby/object:Gem::Requirement
|
93
107
|
requirements:
|
94
108
|
- - ">="
|
95
109
|
- !ruby/object:Gem::Version
|
96
|
-
version: 2.2.
|
110
|
+
version: 2.2.3.0
|
97
111
|
- !ruby/object:Gem::Dependency
|
98
112
|
name: term-ansicolor
|
99
113
|
requirement: !ruby/object:Gem::Requirement
|
@@ -275,8 +289,6 @@ files:
|
|
275
289
|
- lib/i18n/tasks/scanners/ruby_ast_scanner.rb
|
276
290
|
- lib/i18n/tasks/scanners/scanner.rb
|
277
291
|
- lib/i18n/tasks/scanners/scanner_multiplexer.rb
|
278
|
-
- lib/i18n/tasks/scanners/slim_temple_scanner.rb
|
279
|
-
- lib/i18n/tasks/scanners/temple_scanner.rb
|
280
292
|
- lib/i18n/tasks/split_key.rb
|
281
293
|
- lib/i18n/tasks/stats.rb
|
282
294
|
- lib/i18n/tasks/string_interpolation.rb
|
@@ -305,12 +317,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
305
317
|
version: '0'
|
306
318
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
307
319
|
requirements:
|
308
|
-
- - "
|
320
|
+
- - ">="
|
309
321
|
- !ruby/object:Gem::Version
|
310
|
-
version:
|
322
|
+
version: '0'
|
311
323
|
requirements: []
|
312
324
|
rubyforge_project:
|
313
|
-
rubygems_version: 2.4.
|
325
|
+
rubygems_version: 2.4.8
|
314
326
|
signing_key:
|
315
327
|
specification_version: 4
|
316
328
|
summary: Manage localization and translation with the awesome power of static analysis
|
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'i18n/tasks/scanners/temple_scanner'
|
2
|
-
|
3
|
-
module I18n::Tasks::Scanners
|
4
|
-
# Scan slim templates.
|
5
|
-
# Work-in-progress.
|
6
|
-
class SlimTempleScanner < TempleScanner
|
7
|
-
|
8
|
-
def initialize(**args)
|
9
|
-
super(gem_name: 'slim', suggested_gem_version: '~> 3.0', class_name: 'Slim::Parser',
|
10
|
-
requires: %w(slim/parser slim/filter slim/embedded), **args)
|
11
|
-
end
|
12
|
-
|
13
|
-
protected
|
14
|
-
|
15
|
-
def scan_file(path)
|
16
|
-
parser = parser_class.new(file: path)
|
17
|
-
contents = read_file(path)
|
18
|
-
temple_ast = parser.call(contents)
|
19
|
-
# todo: the bare parser is not enough, figure out the modules to use to get to the [:code, ...] IR.
|
20
|
-
$stderr.puts temple_ast.inspect
|
21
|
-
[]
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
@@ -1,33 +0,0 @@
|
|
1
|
-
require 'temple'
|
2
|
-
|
3
|
-
module I18n::Tasks::Scanners
|
4
|
-
# A base class for {Temple}-based scanners.
|
5
|
-
#
|
6
|
-
# @abstract
|
7
|
-
# @since 0.9.0
|
8
|
-
class TempleScanner < FileScanner
|
9
|
-
def initialize(gem_name:, suggested_gem_version:, class_name:, requires:, **args)
|
10
|
-
super(args)
|
11
|
-
@gem_name = gem_name
|
12
|
-
@suggested_gem_version = suggested_gem_version
|
13
|
-
@class_name = class_name
|
14
|
-
@requires = requires
|
15
|
-
@parser_class = nil
|
16
|
-
end
|
17
|
-
|
18
|
-
protected
|
19
|
-
|
20
|
-
# @return [Class<Temple::Parser>]
|
21
|
-
def parser_class
|
22
|
-
@parser_class ||= begin
|
23
|
-
begin
|
24
|
-
Array(@requires).each { |dependency| require dependency }
|
25
|
-
rescue LoadError => e
|
26
|
-
raise ::I18n::Tasks::CommandError.new(
|
27
|
-
e, "#{e.message}: Please add `gem '#{@gem_name}', '#{@suggested_gem_version}'` to the Gemfile.")
|
28
|
-
end
|
29
|
-
ActiveSupport::Inflector.constantize(@class_name)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|