localeapp 0.0.8 → 0.0.10

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 CHANGED
@@ -2,6 +2,7 @@ pkg/*
2
2
  *.gem
3
3
  .bundle
4
4
  Gemfile.lock
5
+ Gemfile.*.lock
5
6
  .yardoc/*
6
7
  doc/*
7
8
  tmp/*
@@ -1,6 +1,10 @@
1
1
  rvm:
2
2
  - 1.8.7
3
3
  - 1.9.2
4
+ gemfile:
5
+ - Gemfile.i18n_037
6
+ - Gemfile.i18n_050
7
+ - Gemfile.i18n_060
4
8
  branches:
5
9
  only:
6
10
  - master
@@ -0,0 +1,5 @@
1
+ source :rubyforge
2
+ gemspec
3
+
4
+ gem 'i18n', '0.3.7'
5
+ gem 'activesupport', '2.3.14'
@@ -0,0 +1,4 @@
1
+ source :rubyforge
2
+ gemspec
3
+
4
+ gem 'i18n', '0.5.0'
@@ -0,0 +1,4 @@
1
+ source :rubyforge
2
+ gemspec
3
+
4
+ gem 'i18n', '~> 0.6.0'
@@ -5,15 +5,24 @@ rescue LoadError
5
5
  # we're in 2.3 and we need to load rails to get the vendored i18n
6
6
  require 'thread' # for rubygems > 1.6.0 support
7
7
  require 'active_support'
8
+ # This ugliness so we can load AS in the travis env
9
+ @loaded_active_support = true
8
10
  end
9
11
 
10
12
  begin
11
13
  require 'i18n/core_ext/hash'
12
14
  rescue LoadError
15
+ # This ugliness so we can load AS in the travis env
13
16
  # Assume that we're in rails 2.3 and AS supplies deep_merge
17
+ # Load AS if we need to
18
+ unless @loaded_active_support
19
+ # we're in 2.3 and we need to load rails to get the vendored i18n
20
+ require 'thread' # for rubygems > 1.6.0 support
21
+ require 'active_support'
22
+ end
14
23
  end
15
24
 
16
-
25
+ require 'localeapp/i18n_shim'
17
26
  require 'localeapp/version'
18
27
  require 'localeapp/configuration'
19
28
  require 'localeapp/routes'
@@ -2,11 +2,12 @@ module Localeapp
2
2
  class ExceptionHandler
3
3
  def self.call(exception, locale, key, options)
4
4
  Localeapp.log(exception.message)
5
- if I18n::MissingTranslationData === exception
5
+ # Which exact exception is set up by our i18n shims
6
+ if exception.is_a? Localeapp::I18nMissingTranslationException
6
7
  Localeapp.log("Detected missing translation for key(s) #{key.inspect}")
7
8
 
8
9
  [*key].each do |key|
9
- Localeapp.missing_translations.add(locale, key, options)
10
+ Localeapp.missing_translations.add(locale, key, options || {})
10
11
  end
11
12
 
12
13
  [locale, key].join(', ')
@@ -0,0 +1,5 @@
1
+ if defined? I18n::MissingTranslation
2
+ Localeapp::I18nMissingTranslationException = I18n::MissingTranslation
3
+ else
4
+ Localeapp::I18nMissingTranslationException = I18n::MissingTranslationData
5
+ end
@@ -38,6 +38,7 @@ module Localeapp
38
38
  end
39
39
 
40
40
  def remove_child_keys!(sub_hash, keys)
41
+ return if sub_hash.nil?
41
42
  current_key = keys.shift
42
43
  if keys.empty?
43
44
  sub_hash.delete(current_key)
@@ -1,3 +1,3 @@
1
1
  module Localeapp
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.10"
3
3
  end
@@ -19,13 +19,11 @@ Gem::Specification.new do |s|
19
19
  s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
20
20
  s.require_paths = ["lib"]
21
21
 
22
+ s.add_dependency('i18n')
22
23
  s.add_dependency('json')
23
24
  s.add_dependency('rest-client')
24
25
  s.add_dependency('ya2yaml')
25
26
 
26
- # i18n is a dev dependency as we'll use whichever version is in rails
27
- # when the gem runs
28
- s.add_development_dependency('i18n', '0.5.0')
29
27
  s.add_development_dependency('rake')
30
28
  s.add_development_dependency('rspec', '2.5.0')
31
29
  s.add_development_dependency('yard', '0.6.7')
@@ -18,4 +18,11 @@ describe Localeapp::ExceptionHandler, '#call(exception, locale, key, options)' d
18
18
  Localeapp.missing_translations.should_receive(:add).with(:en, 'bar', {})
19
19
  I18n.t(['foo', 'bar'])
20
20
  end
21
+
22
+ it "handles missing translation exception" do
23
+ expect {
24
+ exception = Localeapp::I18nMissingTranslationException.new(:en, 'foo', {})
25
+ Localeapp::ExceptionHandler.call(exception, :en, 'foo', {})
26
+ }.to_not raise_error
27
+ end
21
28
  end
@@ -81,9 +81,9 @@ JA
81
81
  it "doesn't create a new yml file if an unknown locale is passed but it has no translations" do
82
82
  do_update({
83
83
  'translations' => {},
84
- 'deletes' => ['foo.delete_me'],
84
+ 'deleted' => ['foo.delete_me'],
85
85
  'locales' => ['ja']
86
86
  })
87
87
  File.exist?(File.join(@yml_dir, 'ja.yml')).should be_false
88
88
  end
89
- end
89
+ end
@@ -3,12 +3,13 @@ require 'localeapp'
3
3
  require 'fakeweb'
4
4
  require 'support/localeapp_integration_data'
5
5
  require 'support/localeapp_synchronization_data'
6
+ require 'support/i18n/missing_translation'
6
7
  require 'logger'
7
8
 
8
9
  def with_configuration(options = {})
9
10
  Localeapp.configuration = nil
10
11
  Localeapp.configure do |configuration|
11
- options.each do |option, value|
12
+ options.each do |option, value|
12
13
  configuration.send("#{option}=", value)
13
14
  end
14
15
  end
@@ -0,0 +1,22 @@
1
+ module I18n
2
+ class MissingTranslation
3
+ attr_reader :locale, :key, :options
4
+
5
+ def initialize(locale, key, options = nil)
6
+ @key, @locale, @options = key, locale, options.dup || {}
7
+ options.each { |k, v| self.options[k] = v.inspect if v.is_a?(Proc) }
8
+ end
9
+
10
+ def keys
11
+ @keys ||= I18n.normalize_keys(locale, key, options[:scope]).tap do |keys|
12
+ keys << 'no key' if keys.size < 2
13
+ end
14
+ end
15
+
16
+ def message
17
+ "translation missing: #{keys.join('.')}"
18
+ end
19
+ alias :to_s :message
20
+
21
+ end
22
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: localeapp
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 11
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 10
10
+ version: 0.0.10
11
11
  platform: ruby
12
12
  authors:
13
13
  - Christopher Dell
@@ -16,10 +16,10 @@ autorequire:
16
16
  bindir: bin
17
17
  cert_chain: []
18
18
 
19
- date: 2011-08-23 00:00:00 Z
19
+ date: 2011-08-25 00:00:00 Z
20
20
  dependencies:
21
21
  - !ruby/object:Gem::Dependency
22
- name: json
22
+ name: i18n
23
23
  prerelease: false
24
24
  requirement: &id001 !ruby/object:Gem::Requirement
25
25
  none: false
@@ -33,7 +33,7 @@ dependencies:
33
33
  type: :runtime
34
34
  version_requirements: *id001
35
35
  - !ruby/object:Gem::Dependency
36
- name: rest-client
36
+ name: json
37
37
  prerelease: false
38
38
  requirement: &id002 !ruby/object:Gem::Requirement
39
39
  none: false
@@ -47,7 +47,7 @@ dependencies:
47
47
  type: :runtime
48
48
  version_requirements: *id002
49
49
  - !ruby/object:Gem::Dependency
50
- name: ya2yaml
50
+ name: rest-client
51
51
  prerelease: false
52
52
  requirement: &id003 !ruby/object:Gem::Requirement
53
53
  none: false
@@ -61,20 +61,18 @@ dependencies:
61
61
  type: :runtime
62
62
  version_requirements: *id003
63
63
  - !ruby/object:Gem::Dependency
64
- name: i18n
64
+ name: ya2yaml
65
65
  prerelease: false
66
66
  requirement: &id004 !ruby/object:Gem::Requirement
67
67
  none: false
68
68
  requirements:
69
- - - "="
69
+ - - ">="
70
70
  - !ruby/object:Gem::Version
71
- hash: 11
71
+ hash: 3
72
72
  segments:
73
73
  - 0
74
- - 5
75
- - 0
76
- version: 0.5.0
77
- type: :development
74
+ version: "0"
75
+ type: :runtime
78
76
  version_requirements: *id004
79
77
  - !ruby/object:Gem::Dependency
80
78
  name: rake
@@ -187,6 +185,9 @@ files:
187
185
  - .rvmrc
188
186
  - .travis.yml
189
187
  - Gemfile
188
+ - Gemfile.i18n_037
189
+ - Gemfile.i18n_050
190
+ - Gemfile.i18n_060
190
191
  - README.textile
191
192
  - Rakefile
192
193
  - bin/localeapp
@@ -205,6 +206,7 @@ files:
205
206
  - lib/localeapp/cli/update.rb
206
207
  - lib/localeapp/configuration.rb
207
208
  - lib/localeapp/exception_handler.rb
209
+ - lib/localeapp/i18n_shim.rb
208
210
  - lib/localeapp/key_checker.rb
209
211
  - lib/localeapp/missing_translations.rb
210
212
  - lib/localeapp/poller.rb
@@ -237,6 +239,7 @@ files:
237
239
  - spec/localeapp/sender_spec.rb
238
240
  - spec/localeapp/updater_spec.rb
239
241
  - spec/spec_helper.rb
242
+ - spec/support/i18n/missing_translation.rb
240
243
  - spec/support/localeapp_integration_data.rb
241
244
  - spec/support/localeapp_synchronization_data.rb
242
245
  homepage: http://rubygems.org/gems/localeapp
@@ -295,5 +298,6 @@ test_files:
295
298
  - spec/localeapp/sender_spec.rb
296
299
  - spec/localeapp/updater_spec.rb
297
300
  - spec/spec_helper.rb
301
+ - spec/support/i18n/missing_translation.rb
298
302
  - spec/support/localeapp_integration_data.rb
299
303
  - spec/support/localeapp_synchronization_data.rb