i18n-debug 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +8 -0
- data/CHANGELOG.md +10 -0
- data/README.md +11 -1
- data/i18n-debug.gemspec +5 -2
- data/lib/i18n/debug.rb +10 -11
- data/lib/i18n/debug/version.rb +1 -1
- data/test/test_i18n_debug.rb +1 -1
- metadata +57 -15
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 70d7f6a748196e4de908ae5202aeed3a72cc6f0c
|
4
|
+
data.tar.gz: 31399b819b4e6d25c4ca20a0b1d947d21ac50122
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 16c9898163fbd402c99110bd4de352bb40663c10efce343df2e56e62e0053b66bb0c6731d81d48506675f61c48b6f5791819a46d2276473e8128d00fc93d6aa1
|
7
|
+
data.tar.gz: d9c004565cf75c236ef0d6a94b68e48694beeea570b89c1ac6f9cc01d45a7ef67d3ac65e1c4448c0de519a3847a08074c6c386c373387cd291b9ad17ebf7e45a
|
data/.travis.yml
ADDED
data/CHANGELOG.md
ADDED
data/README.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Ruby I18n Debug
|
2
2
|
|
3
|
+
[![Build Status][build-image]][build-link]
|
4
|
+
[![Gem Version][gem-image]][gem-link]
|
5
|
+
|
3
6
|
**Ever wondered which translations are being looked up by Rails, a gem, or
|
4
7
|
simply your app? Wonder no more!**
|
5
8
|
|
@@ -33,6 +36,8 @@ Thus, place it inside the `development` group.
|
|
33
36
|
gem 'i18n-debug', group: :development
|
34
37
|
```
|
35
38
|
|
39
|
+
If you need support for ruby < 2, make sure to use version 1.0.0.
|
40
|
+
|
36
41
|
## Usage
|
37
42
|
|
38
43
|
This gem works straight out of the box. If Rails is available, it will log using
|
@@ -54,7 +59,7 @@ totally different, simply set your own handler to do so:
|
|
54
59
|
# Collect stats on I18n key usage.
|
55
60
|
i18n_stats = Hash.new { |stats, key| stats[key] = 0 }
|
56
61
|
|
57
|
-
I18n::Debug.on_lookup
|
62
|
+
I18n::Debug.on_lookup do |key, value|
|
58
63
|
i18n_stats[key] += 1 if value
|
59
64
|
end
|
60
65
|
```
|
@@ -75,3 +80,8 @@ Philipe Fatio ([fphilipe](https://github.com/fphilipe))
|
|
75
80
|
### License
|
76
81
|
|
77
82
|
MIT License. Copyright 2014 Philipe Fatio
|
83
|
+
|
84
|
+
[build-image]: https://travis-ci.org/fphilipe/i18n-debug.svg
|
85
|
+
[build-link]: https://travis-ci.org/fphilipe/i18n-debug
|
86
|
+
[gem-image]: https://badge.fury.io/rb/i18n-debug.svg
|
87
|
+
[gem-link]: https://rubygems.org/gems/i18n-debug
|
data/i18n-debug.gemspec
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
|
1
|
+
require File.expand_path('../lib/i18n/debug/version', __FILE__)
|
2
2
|
|
3
3
|
Gem::Specification.new do |spec|
|
4
4
|
spec.name = 'i18n-debug'
|
@@ -12,5 +12,8 @@ Gem::Specification.new do |spec|
|
|
12
12
|
spec.summary = %q{Ever wondered which translations are being looked up by Rails, a gem, or simply your app? Wonder no more!}
|
13
13
|
spec.description = spec.summary
|
14
14
|
|
15
|
-
spec.
|
15
|
+
spec.add_development_dependency 'bundler', '~> 1.7'
|
16
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
17
|
+
spec.add_development_dependency 'minitest', '~> 5.8'
|
18
|
+
spec.add_dependency 'i18n', '< 1'
|
16
19
|
end
|
data/lib/i18n/debug.rb
CHANGED
@@ -8,7 +8,8 @@ module I18n
|
|
8
8
|
end
|
9
9
|
|
10
10
|
class << self
|
11
|
-
attr_accessor :logger
|
11
|
+
attr_accessor :logger
|
12
|
+
attr_writer :on_lookup
|
12
13
|
|
13
14
|
def logger
|
14
15
|
@logger ||=
|
@@ -19,18 +20,16 @@ module I18n
|
|
19
20
|
::Logger.new($stdout)
|
20
21
|
end
|
21
22
|
end
|
22
|
-
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
alias_method :lookup_without_debug, :lookup
|
28
|
-
alias_method :lookup, :lookup_with_debug
|
29
|
-
end
|
24
|
+
def on_lookup(&blk)
|
25
|
+
return @on_lookup unless block_given?
|
26
|
+
self.on_lookup = blk
|
30
27
|
end
|
28
|
+
end
|
31
29
|
|
32
|
-
|
33
|
-
|
30
|
+
module Hook
|
31
|
+
def lookup(*args)
|
32
|
+
super.tap do |result|
|
34
33
|
options = args.last.is_a?(Hash) ? args.pop : {}
|
35
34
|
separator = options[:separator] || I18n.default_separator
|
36
35
|
key = I18n.normalize_keys(*args, separator).join(separator)
|
@@ -40,5 +39,5 @@ module I18n
|
|
40
39
|
end
|
41
40
|
end
|
42
41
|
|
43
|
-
Backend::Simple.
|
42
|
+
Backend::Simple.prepend(Debug::Hook)
|
44
43
|
end
|
data/lib/i18n/debug/version.rb
CHANGED
data/test/test_i18n_debug.rb
CHANGED
@@ -28,7 +28,7 @@ class TestI18nDebug < Minitest::Test
|
|
28
28
|
def test_custom_lookup_hook_called
|
29
29
|
default_hook = I18n::Debug.on_lookup
|
30
30
|
hook_key, hook_value = nil
|
31
|
-
I18n::Debug.on_lookup
|
31
|
+
I18n::Debug.on_lookup do |key, value|
|
32
32
|
hook_key, hook_value = key, value
|
33
33
|
end
|
34
34
|
|
metadata
CHANGED
@@ -1,37 +1,80 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: i18n-debug
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Philipe Fatio
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2015-08-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
|
-
name: i18n
|
15
14
|
requirement: !ruby/object:Gem::Requirement
|
16
15
|
requirements:
|
17
16
|
- - "~>"
|
18
17
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
20
|
-
|
18
|
+
version: '1.7'
|
19
|
+
name: bundler
|
20
|
+
prerelease: false
|
21
|
+
type: :development
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - "~>"
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '1.7'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
requirement: !ruby/object:Gem::Requirement
|
29
|
+
requirements:
|
30
|
+
- - "~>"
|
31
|
+
- !ruby/object:Gem::Version
|
32
|
+
version: '10.0'
|
33
|
+
name: rake
|
34
|
+
prerelease: false
|
35
|
+
type: :development
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '10.0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
requirement: !ruby/object:Gem::Requirement
|
43
|
+
requirements:
|
44
|
+
- - "~>"
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: '5.8'
|
47
|
+
name: minitest
|
21
48
|
prerelease: false
|
49
|
+
type: :development
|
22
50
|
version_requirements: !ruby/object:Gem::Requirement
|
23
51
|
requirements:
|
24
52
|
- - "~>"
|
25
53
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
27
|
-
|
28
|
-
|
54
|
+
version: '5.8'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
requirement: !ruby/object:Gem::Requirement
|
57
|
+
requirements:
|
58
|
+
- - "<"
|
59
|
+
- !ruby/object:Gem::Version
|
60
|
+
version: '1'
|
61
|
+
name: i18n
|
62
|
+
prerelease: false
|
63
|
+
type: :runtime
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - "<"
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '1'
|
69
|
+
description: Ever wondered which translations are being looked up by Rails, a gem, or simply your app? Wonder no more!
|
29
70
|
email: me@phili.pe
|
30
71
|
executables: []
|
31
72
|
extensions: []
|
32
73
|
extra_rdoc_files: []
|
33
74
|
files:
|
34
75
|
- ".gitignore"
|
76
|
+
- ".travis.yml"
|
77
|
+
- CHANGELOG.md
|
35
78
|
- Gemfile
|
36
79
|
- LICENSE.txt
|
37
80
|
- README.md
|
@@ -44,7 +87,7 @@ homepage: https://github.com/fphilipe/i18n-debug
|
|
44
87
|
licenses:
|
45
88
|
- MIT
|
46
89
|
metadata: {}
|
47
|
-
post_install_message:
|
90
|
+
post_install_message:
|
48
91
|
rdoc_options: []
|
49
92
|
require_paths:
|
50
93
|
- lib
|
@@ -59,11 +102,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
59
102
|
- !ruby/object:Gem::Version
|
60
103
|
version: '0'
|
61
104
|
requirements: []
|
62
|
-
rubyforge_project:
|
63
|
-
rubygems_version: 2.
|
64
|
-
signing_key:
|
105
|
+
rubyforge_project:
|
106
|
+
rubygems_version: 2.4.8
|
107
|
+
signing_key:
|
65
108
|
specification_version: 4
|
66
|
-
summary: Ever wondered which translations are being looked up by Rails, a gem, or
|
67
|
-
simply your app? Wonder no more!
|
109
|
+
summary: Ever wondered which translations are being looked up by Rails, a gem, or simply your app? Wonder no more!
|
68
110
|
test_files:
|
69
111
|
- test/test_i18n_debug.rb
|