localeapp 0.8.0 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +7 -2
- data/README.md +8 -0
- data/lib/localeapp/configuration.rb +6 -0
- data/lib/localeapp/missing_translations.rb +16 -1
- data/lib/localeapp/rails/controller.rb +1 -1
- data/lib/localeapp/version.rb +1 -1
- data/spec/localeapp/configuration_spec.rb +4 -0
- data/spec/localeapp/missing_translations_spec.rb +38 -0
- data/spec/localeapp/rails/controller_spec.rb +6 -0
- metadata +29 -89
data/CHANGELOG.md
CHANGED
@@ -1,11 +1,16 @@
|
|
1
1
|
# master
|
2
2
|
|
3
|
+
# Version 0.8.1
|
4
|
+
|
5
|
+
* Add the `blacklisted_keys_pattern` configuration option
|
6
|
+
* Prevent blacklisted keys from being sent to Locale servers in the Rails exception handler
|
7
|
+
|
3
8
|
# Version 0.8.0
|
4
9
|
|
5
10
|
* Fix problem with line ending in three dots. (@holli)
|
6
11
|
* Change deprecated File.exists? to File.exist?
|
7
|
-
* Fix "install --github" so it
|
8
|
-
|
12
|
+
* Fix "install --github" so it appends README.md. Before it truncated the README.md file with new content, now it appends content in a more correct manner.
|
13
|
+
* Fix .gitignore injection so it ensures a newline.
|
9
14
|
* Extract synchronisation data into SyncFile and SyncData classes. These value objects allow us to read synchronisation data from yaml files that have both strings and symbols as keys. Sync files now use strings as keys when serialising to yaml. If you find that you have a log/localeapp.yml file that contains the string !ruby, run localeapp pull to update to "regular" yaml syntax.
|
10
15
|
* Tweak Aruba config for jRuby (development related only).
|
11
16
|
* Fix minor typo in "updater" output message.
|
data/README.md
CHANGED
@@ -124,6 +124,14 @@ Automatic reloading is only enabled in the development environment by default an
|
|
124
124
|
|
125
125
|
config.reloading_environments = []
|
126
126
|
|
127
|
+
### Blacklisting keys and namespaces (Rails only)
|
128
|
+
|
129
|
+
To prevent certain missing translations from being sent to the Locale servers - in case of automatically generated keys from a gem for example - you can configure the `blacklisted_keys_pattern` option with a regular expression.
|
130
|
+
|
131
|
+
For example, to prevent all keys containing the word "simple_form" :
|
132
|
+
|
133
|
+
config.blacklisted_keys_pattern = /simple_form/
|
134
|
+
|
127
135
|
### Caching
|
128
136
|
|
129
137
|
To prevent localeapp from sending translations every time they are missing, add this config setting:
|
@@ -77,6 +77,12 @@ module Localeapp
|
|
77
77
|
# Enable or disable the missing translation cache
|
78
78
|
# default: false
|
79
79
|
attr_accessor :cache_missing_translations
|
80
|
+
|
81
|
+
# A regular expression that is matched against a translation key.
|
82
|
+
# If the key matches, the translation will not be sent to the Locale
|
83
|
+
# server via the rails exception handler.
|
84
|
+
# default: nil
|
85
|
+
attr_accessor :blacklisted_keys_pattern
|
80
86
|
|
81
87
|
def initialize
|
82
88
|
defaults.each do |setting, value|
|
@@ -1,5 +1,13 @@
|
|
1
1
|
module Localeapp
|
2
|
-
MissingTranslationRecord = Struct.new(:key, :locale, :description, :options)
|
2
|
+
MissingTranslationRecord = Struct.new(:key, :locale, :description, :options) do
|
3
|
+
def blacklisted?
|
4
|
+
key_path.match(Localeapp.configuration.blacklisted_keys_pattern)
|
5
|
+
end
|
6
|
+
|
7
|
+
def key_path
|
8
|
+
[options[:scope], key].compact.join('.')
|
9
|
+
end
|
10
|
+
end
|
3
11
|
|
4
12
|
class MissingTranslations
|
5
13
|
@cached_keys = []
|
@@ -39,6 +47,13 @@ module Localeapp
|
|
39
47
|
data
|
40
48
|
end
|
41
49
|
|
50
|
+
def reject_blacklisted
|
51
|
+
return unless Localeapp.configuration.blacklisted_keys_pattern
|
52
|
+
@translations.each do |locale, records|
|
53
|
+
records.reject! { |key, record| record.blacklisted? }
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
42
57
|
private
|
43
58
|
|
44
59
|
def cached_keys
|
data/lib/localeapp/version.rb
CHANGED
@@ -85,6 +85,10 @@ describe Localeapp::Configuration do
|
|
85
85
|
expect { configuration.daemon_log_file = 'log/la.log' }.to change(configuration, :daemon_log_file).to('log/la.log')
|
86
86
|
end
|
87
87
|
|
88
|
+
it "sets the sending_blacklist by default" do
|
89
|
+
expect(configuration.blacklisted_keys_pattern).to be_nil
|
90
|
+
end
|
91
|
+
|
88
92
|
context "enabled_sending_environments" do
|
89
93
|
it "is only development by default" do
|
90
94
|
configuration.sending_environments.should == ['development']
|
@@ -61,3 +61,41 @@ describe Localeapp::MissingTranslations, "#to_send" do
|
|
61
61
|
end
|
62
62
|
end
|
63
63
|
end
|
64
|
+
|
65
|
+
describe Localeapp::MissingTranslations, "#reject_blacklisted" do
|
66
|
+
let(:translations) { Localeapp::MissingTranslations.new }
|
67
|
+
let(:count) { Proc.new { translations.to_send.count } }
|
68
|
+
|
69
|
+
before do
|
70
|
+
translations.add(:en, 'feline.lion')
|
71
|
+
translations.add(:en, 'feline.tiger')
|
72
|
+
translations.add(:en, 'bird.eagle')
|
73
|
+
translations.add(:de, 'crow', nil, {:scope => 'bird'})
|
74
|
+
translations.add(:fr, 'feline.lion')
|
75
|
+
translations.add(:fr, 'reptile.lizard')
|
76
|
+
end
|
77
|
+
|
78
|
+
it "removes translations whose key matches the blacklisted_keys_pattern" do
|
79
|
+
with_configuration(:blacklisted_keys_pattern => /^feline/) do
|
80
|
+
expect { translations.reject_blacklisted }.to change(count, :call).by(-3)
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
it "removes translations whose scope matches the blacklisted_keys_pattern" do
|
85
|
+
with_configuration(:blacklisted_keys_pattern => /^bird\./) do
|
86
|
+
expect { translations.reject_blacklisted }.to change(count, :call).by(-2)
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
90
|
+
it "does nothing when blacklisted_keys_pattern is nil" do
|
91
|
+
with_configuration do
|
92
|
+
expect { translations.reject_blacklisted }.to_not change(count, :call)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
|
96
|
+
it "does nothing when blacklisted_keys_pattern does not match anything" do
|
97
|
+
with_configuration(:blacklisted_keys_pattern => /^canine/) do
|
98
|
+
expect { translations.reject_blacklisted }.to_not change(count, :call)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
@@ -136,4 +136,10 @@ describe Localeapp::Rails::Controller, '#send_missing_translations' do
|
|
136
136
|
Localeapp.sender.should_receive(:post_missing_translations)
|
137
137
|
@controller.send_missing_translations
|
138
138
|
end
|
139
|
+
|
140
|
+
it "rejects blacklisted translations" do
|
141
|
+
Localeapp.configuration.environment_name = 'development'
|
142
|
+
Localeapp.missing_translations.should_receive(:reject_blacklisted)
|
143
|
+
@controller.send_missing_translations
|
144
|
+
end
|
139
145
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: localeapp
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.8.
|
4
|
+
version: 0.8.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -10,11 +10,11 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2014-
|
13
|
+
date: 2014-07-10 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: i18n
|
17
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirement: &70249449874240 !ruby/object:Gem::Requirement
|
18
18
|
none: false
|
19
19
|
requirements:
|
20
20
|
- - ! '>='
|
@@ -22,15 +22,10 @@ dependencies:
|
|
22
22
|
version: '0'
|
23
23
|
type: :runtime
|
24
24
|
prerelease: false
|
25
|
-
version_requirements:
|
26
|
-
none: false
|
27
|
-
requirements:
|
28
|
-
- - ! '>='
|
29
|
-
- !ruby/object:Gem::Version
|
30
|
-
version: '0'
|
25
|
+
version_requirements: *70249449874240
|
31
26
|
- !ruby/object:Gem::Dependency
|
32
27
|
name: json
|
33
|
-
requirement: !ruby/object:Gem::Requirement
|
28
|
+
requirement: &70249449873440 !ruby/object:Gem::Requirement
|
34
29
|
none: false
|
35
30
|
requirements:
|
36
31
|
- - ! '>='
|
@@ -38,15 +33,10 @@ dependencies:
|
|
38
33
|
version: '0'
|
39
34
|
type: :runtime
|
40
35
|
prerelease: false
|
41
|
-
version_requirements:
|
42
|
-
none: false
|
43
|
-
requirements:
|
44
|
-
- - ! '>='
|
45
|
-
- !ruby/object:Gem::Version
|
46
|
-
version: '0'
|
36
|
+
version_requirements: *70249449873440
|
47
37
|
- !ruby/object:Gem::Dependency
|
48
38
|
name: rest-client
|
49
|
-
requirement: !ruby/object:Gem::Requirement
|
39
|
+
requirement: &70249449872140 !ruby/object:Gem::Requirement
|
50
40
|
none: false
|
51
41
|
requirements:
|
52
42
|
- - ! '>='
|
@@ -54,15 +44,10 @@ dependencies:
|
|
54
44
|
version: '0'
|
55
45
|
type: :runtime
|
56
46
|
prerelease: false
|
57
|
-
version_requirements:
|
58
|
-
none: false
|
59
|
-
requirements:
|
60
|
-
- - ! '>='
|
61
|
-
- !ruby/object:Gem::Version
|
62
|
-
version: '0'
|
47
|
+
version_requirements: *70249449872140
|
63
48
|
- !ruby/object:Gem::Dependency
|
64
49
|
name: rack
|
65
|
-
requirement: !ruby/object:Gem::Requirement
|
50
|
+
requirement: &70249449892660 !ruby/object:Gem::Requirement
|
66
51
|
none: false
|
67
52
|
requirements:
|
68
53
|
- - ! '>='
|
@@ -70,15 +55,10 @@ dependencies:
|
|
70
55
|
version: '0'
|
71
56
|
type: :runtime
|
72
57
|
prerelease: false
|
73
|
-
version_requirements:
|
74
|
-
none: false
|
75
|
-
requirements:
|
76
|
-
- - ! '>='
|
77
|
-
- !ruby/object:Gem::Version
|
78
|
-
version: '0'
|
58
|
+
version_requirements: *70249449892660
|
79
59
|
- !ruby/object:Gem::Dependency
|
80
60
|
name: ya2yaml
|
81
|
-
requirement: !ruby/object:Gem::Requirement
|
61
|
+
requirement: &70249449891000 !ruby/object:Gem::Requirement
|
82
62
|
none: false
|
83
63
|
requirements:
|
84
64
|
- - ! '>='
|
@@ -86,15 +66,10 @@ dependencies:
|
|
86
66
|
version: '0'
|
87
67
|
type: :runtime
|
88
68
|
prerelease: false
|
89
|
-
version_requirements:
|
90
|
-
none: false
|
91
|
-
requirements:
|
92
|
-
- - ! '>='
|
93
|
-
- !ruby/object:Gem::Version
|
94
|
-
version: '0'
|
69
|
+
version_requirements: *70249449891000
|
95
70
|
- !ruby/object:Gem::Dependency
|
96
71
|
name: gli
|
97
|
-
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirement: &70249449889260 !ruby/object:Gem::Requirement
|
98
73
|
none: false
|
99
74
|
requirements:
|
100
75
|
- - ! '>='
|
@@ -102,15 +77,10 @@ dependencies:
|
|
102
77
|
version: '0'
|
103
78
|
type: :runtime
|
104
79
|
prerelease: false
|
105
|
-
version_requirements:
|
106
|
-
none: false
|
107
|
-
requirements:
|
108
|
-
- - ! '>='
|
109
|
-
- !ruby/object:Gem::Version
|
110
|
-
version: '0'
|
80
|
+
version_requirements: *70249449889260
|
111
81
|
- !ruby/object:Gem::Dependency
|
112
82
|
name: rake
|
113
|
-
requirement: !ruby/object:Gem::Requirement
|
83
|
+
requirement: &70249449888160 !ruby/object:Gem::Requirement
|
114
84
|
none: false
|
115
85
|
requirements:
|
116
86
|
- - ! '>='
|
@@ -118,15 +88,10 @@ dependencies:
|
|
118
88
|
version: '0'
|
119
89
|
type: :development
|
120
90
|
prerelease: false
|
121
|
-
version_requirements:
|
122
|
-
none: false
|
123
|
-
requirements:
|
124
|
-
- - ! '>='
|
125
|
-
- !ruby/object:Gem::Version
|
126
|
-
version: '0'
|
91
|
+
version_requirements: *70249449888160
|
127
92
|
- !ruby/object:Gem::Dependency
|
128
93
|
name: rspec
|
129
|
-
requirement: !ruby/object:Gem::Requirement
|
94
|
+
requirement: &70249449887060 !ruby/object:Gem::Requirement
|
130
95
|
none: false
|
131
96
|
requirements:
|
132
97
|
- - ~>
|
@@ -134,15 +99,10 @@ dependencies:
|
|
134
99
|
version: 2.14.1
|
135
100
|
type: :development
|
136
101
|
prerelease: false
|
137
|
-
version_requirements:
|
138
|
-
none: false
|
139
|
-
requirements:
|
140
|
-
- - ~>
|
141
|
-
- !ruby/object:Gem::Version
|
142
|
-
version: 2.14.1
|
102
|
+
version_requirements: *70249449887060
|
143
103
|
- !ruby/object:Gem::Dependency
|
144
104
|
name: yard
|
145
|
-
requirement: !ruby/object:Gem::Requirement
|
105
|
+
requirement: &70249449966160 !ruby/object:Gem::Requirement
|
146
106
|
none: false
|
147
107
|
requirements:
|
148
108
|
- - ! '>='
|
@@ -150,15 +110,10 @@ dependencies:
|
|
150
110
|
version: '0'
|
151
111
|
type: :development
|
152
112
|
prerelease: false
|
153
|
-
version_requirements:
|
154
|
-
none: false
|
155
|
-
requirements:
|
156
|
-
- - ! '>='
|
157
|
-
- !ruby/object:Gem::Version
|
158
|
-
version: '0'
|
113
|
+
version_requirements: *70249449966160
|
159
114
|
- !ruby/object:Gem::Dependency
|
160
115
|
name: RedCloth
|
161
|
-
requirement: !ruby/object:Gem::Requirement
|
116
|
+
requirement: &70249449961880 !ruby/object:Gem::Requirement
|
162
117
|
none: false
|
163
118
|
requirements:
|
164
119
|
- - ! '>='
|
@@ -166,15 +121,10 @@ dependencies:
|
|
166
121
|
version: '0'
|
167
122
|
type: :development
|
168
123
|
prerelease: false
|
169
|
-
version_requirements:
|
170
|
-
none: false
|
171
|
-
requirements:
|
172
|
-
- - ! '>='
|
173
|
-
- !ruby/object:Gem::Version
|
174
|
-
version: '0'
|
124
|
+
version_requirements: *70249449961880
|
175
125
|
- !ruby/object:Gem::Dependency
|
176
126
|
name: aruba
|
177
|
-
requirement: !ruby/object:Gem::Requirement
|
127
|
+
requirement: &70249449959460 !ruby/object:Gem::Requirement
|
178
128
|
none: false
|
179
129
|
requirements:
|
180
130
|
- - ! '>='
|
@@ -182,15 +132,10 @@ dependencies:
|
|
182
132
|
version: '0'
|
183
133
|
type: :development
|
184
134
|
prerelease: false
|
185
|
-
version_requirements:
|
186
|
-
none: false
|
187
|
-
requirements:
|
188
|
-
- - ! '>='
|
189
|
-
- !ruby/object:Gem::Version
|
190
|
-
version: '0'
|
135
|
+
version_requirements: *70249449959460
|
191
136
|
- !ruby/object:Gem::Dependency
|
192
137
|
name: fakeweb
|
193
|
-
requirement: !ruby/object:Gem::Requirement
|
138
|
+
requirement: &70249449995660 !ruby/object:Gem::Requirement
|
194
139
|
none: false
|
195
140
|
requirements:
|
196
141
|
- - ! '>='
|
@@ -198,12 +143,7 @@ dependencies:
|
|
198
143
|
version: '0'
|
199
144
|
type: :development
|
200
145
|
prerelease: false
|
201
|
-
version_requirements:
|
202
|
-
none: false
|
203
|
-
requirements:
|
204
|
-
- - ! '>='
|
205
|
-
- !ruby/object:Gem::Version
|
206
|
-
version: '0'
|
146
|
+
version_requirements: *70249449995660
|
207
147
|
description: Synchronizes i18n translation keys and content with localeapp.com so
|
208
148
|
you don't have to manage translations by hand.
|
209
149
|
email:
|
@@ -320,7 +260,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
320
260
|
version: '0'
|
321
261
|
segments:
|
322
262
|
- 0
|
323
|
-
hash:
|
263
|
+
hash: -1665845517778258458
|
324
264
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
325
265
|
none: false
|
326
266
|
requirements:
|
@@ -329,10 +269,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
329
269
|
version: '0'
|
330
270
|
segments:
|
331
271
|
- 0
|
332
|
-
hash:
|
272
|
+
hash: -1665845517778258458
|
333
273
|
requirements: []
|
334
274
|
rubyforge_project: localeapp
|
335
|
-
rubygems_version: 1.8.
|
275
|
+
rubygems_version: 1.8.6
|
336
276
|
signing_key:
|
337
277
|
specification_version: 3
|
338
278
|
summary: Easy i18n translation management with localeapp.com
|