untranslated 1.0.2
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/.gitignore +17 -0
- data/Gemfile +6 -0
- data/Gemfile.lock +20 -0
- data/LICENSE.txt +22 -0
- data/README.md +5 -0
- data/Rakefile +1 -0
- data/lib/untranslated.rb +11 -0
- data/lib/untranslated/spy.rb +63 -0
- data/lib/untranslated/version.rb +3 -0
- data/log/untranslated.en.yml +15 -0
- data/spec/fallback_spec.rb +33 -0
- data/spec/spec_helper.rb +7 -0
- data/untranslated.gemspec +22 -0
- metadata +94 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
untranslated (1.0.2)
|
5
|
+
hash-deep-merge
|
6
|
+
i18n
|
7
|
+
|
8
|
+
GEM
|
9
|
+
remote: https://rubygems.org/
|
10
|
+
specs:
|
11
|
+
hash-deep-merge (0.1.1)
|
12
|
+
i18n (0.6.1)
|
13
|
+
rake (0.9.2.2)
|
14
|
+
|
15
|
+
PLATFORMS
|
16
|
+
ruby
|
17
|
+
|
18
|
+
DEPENDENCIES
|
19
|
+
rake
|
20
|
+
untranslated!
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2012 Heimdell
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
data/Rakefile
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
require "bundler/gem_tasks"
|
data/lib/untranslated.rb
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
module Untranslated
|
2
|
+
|
3
|
+
class Spy < ::I18n::ExceptionHandler
|
4
|
+
|
5
|
+
def call(exception, locale, key, options)
|
6
|
+
push locale, key
|
7
|
+
|
8
|
+
super(exception, locale, key, options)
|
9
|
+
end
|
10
|
+
|
11
|
+
def push locale, key
|
12
|
+
path = [locale, key].join ::I18n.default_separator
|
13
|
+
packed = pack path
|
14
|
+
keys.deep_merge! packed
|
15
|
+
|
16
|
+
cached_store key
|
17
|
+
end
|
18
|
+
|
19
|
+
def pack key
|
20
|
+
path = key.split ::I18n.default_separator
|
21
|
+
|
22
|
+
reverse_path = path.reverse
|
23
|
+
|
24
|
+
reverse_path.inject('') do |hash, k|
|
25
|
+
out = {}
|
26
|
+
out[k] = hash
|
27
|
+
out
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def cached_store key
|
32
|
+
@cache ||= {}
|
33
|
+
|
34
|
+
store unless @cache[key]
|
35
|
+
|
36
|
+
@cache[key] ||= true
|
37
|
+
end
|
38
|
+
|
39
|
+
def store
|
40
|
+
ensure_log_dir_exist
|
41
|
+
|
42
|
+
keys.each do |locale, key|
|
43
|
+
::File.open("./log/untranslated.#{locale}.yml", 'w') do |f|
|
44
|
+
prefixed = {}
|
45
|
+
prefixed[locale] = key
|
46
|
+
f.write(prefixed.to_yaml)
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def ensure_log_dir_exist
|
52
|
+
return if Dir.exist? './log'
|
53
|
+
|
54
|
+
Dir.mkdir './log'
|
55
|
+
end
|
56
|
+
|
57
|
+
def keys
|
58
|
+
@keys ||= {}
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Untranslated do
|
4
|
+
it "should save all keys, untranslated by I18n" do
|
5
|
+
Untranslated.install
|
6
|
+
|
7
|
+
::I18n.t "unary_test"
|
8
|
+
::I18n.t "this.key.not.exist"
|
9
|
+
::I18n.t "this.key.not.existent.too"
|
10
|
+
::I18n.t "this.is.same"
|
11
|
+
::I18n.t "just.trying.to.test"
|
12
|
+
|
13
|
+
require "yaml"
|
14
|
+
|
15
|
+
hash = YAML.load_file "log/untranslated.en.yml"
|
16
|
+
|
17
|
+
hash.should == {
|
18
|
+
'en' => {
|
19
|
+
'unary_test' => '',
|
20
|
+
'this' => {
|
21
|
+
'key' => {
|
22
|
+
'not' => {
|
23
|
+
'exist' => '',
|
24
|
+
'existent' => { 'too' => '' }
|
25
|
+
}
|
26
|
+
},
|
27
|
+
'is' => { 'same' => '' }
|
28
|
+
},
|
29
|
+
'just' => { 'trying' => { 'to' => { 'test' => '' } } }
|
30
|
+
}
|
31
|
+
}
|
32
|
+
end
|
33
|
+
end
|
data/spec/spec_helper.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
lib = File.expand_path('../lib', __FILE__)
|
3
|
+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
|
+
require 'untranslated/version'
|
5
|
+
|
6
|
+
Gem::Specification.new do |gem|
|
7
|
+
gem.name = "untranslated"
|
8
|
+
gem.version = Untranslated::VERSION
|
9
|
+
gem.authors = ["Heimdell"]
|
10
|
+
gem.email = ["hindmost.one@gmail.com"]
|
11
|
+
gem.description = "This gem sniffers your untranslated keys and store them as they come to ./log"
|
12
|
+
gem.summary = "Detector of untranslated keys."
|
13
|
+
gem.homepage = ""
|
14
|
+
|
15
|
+
gem.add_dependency "i18n"
|
16
|
+
gem.add_dependency "hash-deep-merge"
|
17
|
+
|
18
|
+
gem.files = `git ls-files`.split($/)
|
19
|
+
gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
20
|
+
gem.test_files = gem.files.grep(%r{^(spec|spec|features)/})
|
21
|
+
gem.require_paths = ["lib"]
|
22
|
+
end
|
metadata
ADDED
@@ -0,0 +1,94 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: untranslated
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 1.0.2
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Heimdell
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2012-10-31 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: i18n
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ! '>='
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: '0'
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ! '>='
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: '0'
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: hash-deep-merge
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: This gem sniffers your untranslated keys and store them as they come
|
47
|
+
to ./log
|
48
|
+
email:
|
49
|
+
- hindmost.one@gmail.com
|
50
|
+
executables: []
|
51
|
+
extensions: []
|
52
|
+
extra_rdoc_files: []
|
53
|
+
files:
|
54
|
+
- .gitignore
|
55
|
+
- Gemfile
|
56
|
+
- Gemfile.lock
|
57
|
+
- LICENSE.txt
|
58
|
+
- README.md
|
59
|
+
- Rakefile
|
60
|
+
- lib/untranslated.rb
|
61
|
+
- lib/untranslated/spy.rb
|
62
|
+
- lib/untranslated/version.rb
|
63
|
+
- log/untranslated.en.yml
|
64
|
+
- spec/fallback_spec.rb
|
65
|
+
- spec/spec_helper.rb
|
66
|
+
- untranslated.gemspec
|
67
|
+
homepage: ''
|
68
|
+
licenses: []
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options: []
|
71
|
+
require_paths:
|
72
|
+
- lib
|
73
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: '0'
|
79
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
requirements: []
|
86
|
+
rubyforge_project:
|
87
|
+
rubygems_version: 1.8.24
|
88
|
+
signing_key:
|
89
|
+
specification_version: 3
|
90
|
+
summary: Detector of untranslated keys.
|
91
|
+
test_files:
|
92
|
+
- spec/fallback_spec.rb
|
93
|
+
- spec/spec_helper.rb
|
94
|
+
has_rdoc:
|