i18n_translation_spawner 0.0.8 → 0.0.9

Sign up to get free protection for your applications and to get access to all the features.
Files changed (2) hide show
  1. data/lib/i18n_translation_spawner.rb +13 -9
  2. metadata +3 -3
@@ -11,7 +11,7 @@ module I18n
11
11
  attr_accessor_with_default :skip_locales, []
12
12
  attr_accessor_with_default :removable_prefixes, %w()
13
13
  attr_accessor_with_default :default_translations, {}
14
- attr_accessor :exception_handler, :key_translations_handler, :translations_handler, :file_path_decoder
14
+ attr_accessor :exception_handler, :key_translations_handler, :translations_handler, :file_path_decoder, :cannot_decode_translation_file_path_handler
15
15
 
16
16
  private
17
17
 
@@ -49,8 +49,12 @@ module I18n
49
49
  File.open(path, 'w') { |f| f.write(YAML.unescape(translations_hash.ya2yaml)) }
50
50
  end
51
51
  rescue CannotDecodeTranslationFilePath
52
- Rails.logger.info "=== Cannot access translation file for #{key.to_s}"
53
- return(options[:rescue_format] == :html ? exception.html_message : exception.message)
52
+ if cannot_decode_translation_file_path_handler.respond_to?(:call)
53
+ cannot_decode_translation_file_path_handler.call(key,locale,options,exception)
54
+ else
55
+ Rails.logger.info "=== Cannot access translation file for #{key.to_s}"
56
+ return(options[:rescue_format] == :html ? exception.html_message : exception.message)
57
+ end
54
58
  end
55
59
  end
56
60
  translation(key, locale.to_s)
@@ -68,7 +72,7 @@ module I18n
68
72
 
69
73
  def default_translation(key, locale)
70
74
  if translations_handler.respond_to?(:call)
71
- translations_handler(key, locale, self)
75
+ translations_handler(key, locale, self)
72
76
  else
73
77
  _key = key.dup
74
78
  while _key.present?
@@ -100,12 +104,12 @@ module I18n
100
104
 
101
105
  def handle_exception(exception, locale, key, options)
102
106
  case exception
103
- when I18n::MissingTranslationData
104
- spawn_translation_key(key, locale, options, exception)
105
- else
106
- raise exception
107
+ when I18n::MissingTranslationData
108
+ spawn_translation_key(key, locale, options, exception)
109
+ else
110
+ raise exception
107
111
  end
108
112
  end
109
113
 
110
114
  end
111
- end
115
+ end
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: i18n_translation_spawner
3
3
  version: !ruby/object:Gem::Version
4
- hash: 15
4
+ hash: 13
5
5
  prerelease:
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 8
10
- version: 0.0.8
9
+ - 9
10
+ version: 0.0.9
11
11
  platform: ruby
12
12
  authors:
13
13
  - "B\xC5\x82a\xC5\xBCej --Stevo-- Kosmowski"