voltron-translate 0.2.2 → 0.2.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d63716690236d33ce9d8497b2e4e84c7ee9355a3
4
- data.tar.gz: 6d4fef31cd140a923b02ca508169b5470aab9612
3
+ metadata.gz: 045a274049337b0932c8fee549b93e3f1f65115c
4
+ data.tar.gz: 5042363216c2aa619ff1511aceaee2e6dd9b5ffa
5
5
  SHA512:
6
- metadata.gz: 6e357d22054599503b00a94deaf3a9e065e21f574f26e3fe2dabf8c585339ed235647816c4981d066815c41ddd02f50bed672555faf429f8e31601ab57dd8726
7
- data.tar.gz: 3a8b8c93887fba7de22eed4b4e70e11989b7cd689f861767bc3a25783bd71eb12c913d71ef4c08909fe6cea58e04ed9f08f1c74e828a0674e0c196c2a180ebc0
6
+ metadata.gz: ae0899b478d78a72895a06b8fdc44afb48732acedd0bc12dfd73aa18fc1f60abe79981bd08bbc4bfdb7c23a7070daa5f0f9a866a33b41569bb79be0f9bbb1cfd
7
+ data.tar.gz: 0e2ca43dc4f173c69534746990ad692a9de412e756bdcb00292acba9ba12c748e78bbff9e6a1692e3a82ed72b09d0cfc6c0e47079548f5a2e5235289655bde42
@@ -14,32 +14,32 @@ module Voltron
14
14
 
15
15
  class InvalidColumnTypeError < StandardError; end
16
16
 
17
- def __(text, locale = I18n.locale, **args)
18
- return (text % args) unless Voltron.config.translate.enabled?
17
+ def _(locale = I18n.locale, **args)
18
+ return (self % args) if !Voltron.config.translate.enabled? || self.blank?
19
19
 
20
20
  begin
21
21
  raise 'Locale can only contain the characters A-Z, and _' unless locale.to_s =~ /^[A-Z_]+$/i
22
22
 
23
23
  # If app is running in one of the environments where translations can be created
24
24
  if Voltron.config.translate.buildable?
25
- Array.wrap(Voltron.config.translate.locales).compact.each { |locale| translator(locale).write text }
25
+ Array.wrap(Voltron.config.translate.locales).compact.each { |locale| translator(locale).write self }
26
26
  end
27
27
 
28
28
  # Translate the text and return it
29
- translator(locale).translate text, **args
29
+ translator(locale).translate self, **args
30
30
  rescue => e
31
31
  # If any errors occurred, log the error and just return the default interpolated text
32
- Voltron.log e.message.to_s + " (Original Translation Text: #{text})", 'Translate', ::Voltron::Translate::LOG_COLOR
33
- text % args
32
+ Voltron.log e.message.to_s + " (Original Translation Text: #{self})", 'Translate', ::Voltron::Translate::LOG_COLOR
33
+ self % args
34
34
  end
35
35
  end
36
36
 
37
37
  def translator(locale = I18n.locale)
38
38
  @translators ||= {}
39
- @translators[locale.to_s] ||= Translation.new(locale)
39
+ @translators[locale.to_s] ||= Translator.new(locale)
40
40
  end
41
41
 
42
- class Translation
42
+ class Translator
43
43
 
44
44
  attr_accessor :locale
45
45
 
@@ -5,12 +5,8 @@ module Voltron
5
5
  isolate_namespace Voltron
6
6
 
7
7
  initializer 'voltron.translate.initialize' do
8
- ::ActionController::Base.send :include, ::Voltron::Translate
9
- ::ActiveRecord::Base.send :include, ::Voltron::Translate
10
- ::ActiveRecord::Base.send :extend, ::Voltron::Translate
11
8
  ::ActiveRecord::Base.send :extend, ::Voltron::Translatable
12
- ::ActionView::Base.send :include, ::Voltron::Translate
13
- ::ActionMailer::Base.send :include, ::Voltron::Translate
9
+ ::String.send :include, ::Voltron::Translate
14
10
  end
15
11
  end
16
12
  end
@@ -1,5 +1,5 @@
1
1
  module Voltron
2
2
  module Translate
3
- VERSION = '0.2.2'.freeze
3
+ VERSION = '0.2.3'.freeze
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: voltron-translate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Eric Hainer
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2017-07-25 00:00:00.000000000 Z
11
+ date: 2017-10-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails