i18n_tools 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/i18n_tools/missing_scanner.rb +22 -5
- data/lib/i18n_tools/scanner.rb +4 -4
- data/lib/i18n_tools/unused_scanner.rb +1 -1
- metadata +33 -36
@@ -7,21 +7,38 @@ module I18nTools
|
|
7
7
|
def results
|
8
8
|
missing_ones = []
|
9
9
|
|
10
|
-
scan do |key|
|
11
|
-
missing_ones << key unless I18n.backend.send(:lookup, @locale, key)
|
10
|
+
scan do |key, params|
|
11
|
+
missing_ones << [key, params] unless I18n.backend.send(:lookup, @locale, key)
|
12
12
|
end
|
13
13
|
|
14
14
|
result = {}
|
15
15
|
|
16
|
-
missing_ones.each do |key|
|
16
|
+
missing_ones.each do |key, params|
|
17
17
|
current_hash = result
|
18
18
|
parts = key.split(".")
|
19
19
|
parts[0..-2].each do |part|
|
20
20
|
current_hash[part] ||= {}
|
21
21
|
current_hash = current_hash[part]
|
22
22
|
end
|
23
|
-
|
24
|
-
|
23
|
+
|
24
|
+
if params.blank?
|
25
|
+
content = ""
|
26
|
+
else
|
27
|
+
keys = []
|
28
|
+
|
29
|
+
parsed = params.split(",").map {|x|x.scan(/(:[a-zA-Z0-9_]+)\s*=>\s*(.*)/)}
|
30
|
+
parsed.each do |param|
|
31
|
+
next if param.blank?
|
32
|
+
|
33
|
+
key, value = *param.flatten
|
34
|
+
|
35
|
+
keys << "%{#{key.sub(/^:/, '')}} (#{value})"
|
36
|
+
end
|
37
|
+
|
38
|
+
content = keys.join(", ")
|
39
|
+
end
|
40
|
+
|
41
|
+
current_hash[parts.last] = content
|
25
42
|
end
|
26
43
|
|
27
44
|
result
|
data/lib/i18n_tools/scanner.rb
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
module I18nTools
|
2
2
|
class Scanner
|
3
|
-
VIEW_REGEXPS = [/[^\w]t\(\"(.*?)\"
|
4
|
-
CODE_REGEXPS = [/I18n\.t\(\"(.*?)\"
|
3
|
+
VIEW_REGEXPS = [/[^\w]t\(\"(.*?)\"(.*?)\)/, /[^\w]t\(\'(.*?)\'(.*?)\)/]
|
4
|
+
CODE_REGEXPS = [/I18n\.t\(\"(.*?)\"(.*?)\)/, /I18n\.t\(\'(.*?)\'(.*?)\)/]
|
5
5
|
|
6
6
|
cattr_accessor :file_types
|
7
7
|
self.file_types = ['controllers', 'helpers', 'models']
|
@@ -20,13 +20,13 @@ module I18nTools
|
|
20
20
|
content = File.read(filename)
|
21
21
|
VIEW_REGEXPS.each do |view_regexp|
|
22
22
|
content.scan(view_regexp) do |match|
|
23
|
-
key = match.first
|
23
|
+
key, params = match.first, match.last
|
24
24
|
next if key =~ /\#\{/
|
25
25
|
if key =~ /^\./
|
26
26
|
namespace = filename.gsub('app/views/', '').gsub('.html.erb', '').gsub('/', '.')
|
27
27
|
key = (namespace + key).split('.').collect { |part| part.gsub(/^\_/, '') }.join('.')
|
28
28
|
end
|
29
|
-
yield key
|
29
|
+
yield key, params
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
metadata
CHANGED
@@ -1,37 +1,38 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n_tools
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.1
|
4
5
|
prerelease:
|
5
|
-
version: 0.1.0
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Thomas Kadauke
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
- !ruby/object:Gem::Dependency
|
12
|
+
date: 2013-03-11 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
16
15
|
name: ya2yaml
|
17
|
-
|
18
|
-
requirement: &id001 !ruby/object:Gem::Requirement
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
19
17
|
none: false
|
20
|
-
requirements:
|
21
|
-
- -
|
22
|
-
- !ruby/object:Gem::Version
|
23
|
-
version:
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
24
22
|
type: :runtime
|
25
|
-
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
26
30
|
description:
|
27
|
-
email:
|
31
|
+
email: thomas.kadauke@googlemail.com
|
28
32
|
executables: []
|
29
|
-
|
30
33
|
extensions: []
|
31
|
-
|
32
34
|
extra_rdoc_files: []
|
33
|
-
|
34
|
-
files:
|
35
|
+
files:
|
35
36
|
- lib/i18n_tools/missing_scanner.rb
|
36
37
|
- lib/i18n_tools/railtie.rb
|
37
38
|
- lib/i18n_tools/scanner.rb
|
@@ -40,30 +41,26 @@ files:
|
|
40
41
|
- tasks/i18n_tools.rake
|
41
42
|
homepage:
|
42
43
|
licenses: []
|
43
|
-
|
44
44
|
post_install_message:
|
45
45
|
rdoc_options: []
|
46
|
-
|
47
|
-
require_paths:
|
46
|
+
require_paths:
|
48
47
|
- lib
|
49
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
48
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
50
49
|
none: false
|
51
|
-
requirements:
|
52
|
-
- -
|
53
|
-
- !ruby/object:Gem::Version
|
54
|
-
version:
|
55
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
50
|
+
requirements:
|
51
|
+
- - ! '>='
|
52
|
+
- !ruby/object:Gem::Version
|
53
|
+
version: '0'
|
54
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
56
55
|
none: false
|
57
|
-
requirements:
|
58
|
-
- -
|
59
|
-
- !ruby/object:Gem::Version
|
60
|
-
version:
|
56
|
+
requirements:
|
57
|
+
- - ! '>='
|
58
|
+
- !ruby/object:Gem::Version
|
59
|
+
version: '0'
|
61
60
|
requirements: []
|
62
|
-
|
63
61
|
rubyforge_project:
|
64
|
-
rubygems_version: 1.8.
|
62
|
+
rubygems_version: 1.8.24
|
65
63
|
signing_key:
|
66
64
|
specification_version: 3
|
67
65
|
summary: Tasks for extracting missing and unused translations from Rails projects
|
68
66
|
test_files: []
|
69
|
-
|