voltron-translate 0.2.2 → 0.2.3
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.
- checksums.yaml +4 -4
- data/lib/voltron/translate.rb +8 -8
- data/lib/voltron/translate/engine.rb +1 -5
- data/lib/voltron/translate/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 045a274049337b0932c8fee549b93e3f1f65115c
|
4
|
+
data.tar.gz: 5042363216c2aa619ff1511aceaee2e6dd9b5ffa
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ae0899b478d78a72895a06b8fdc44afb48732acedd0bc12dfd73aa18fc1f60abe79981bd08bbc4bfdb7c23a7070daa5f0f9a866a33b41569bb79be0f9bbb1cfd
|
7
|
+
data.tar.gz: 0e2ca43dc4f173c69534746990ad692a9de412e756bdcb00292acba9ba12c748e78bbff9e6a1692e3a82ed72b09d0cfc6c0e47079548f5a2e5235289655bde42
|
data/lib/voltron/translate.rb
CHANGED
@@ -14,32 +14,32 @@ module Voltron
|
|
14
14
|
|
15
15
|
class InvalidColumnTypeError < StandardError; end
|
16
16
|
|
17
|
-
def
|
18
|
-
return (
|
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
|
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
|
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: #{
|
33
|
-
|
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] ||=
|
39
|
+
@translators[locale.to_s] ||= Translator.new(locale)
|
40
40
|
end
|
41
41
|
|
42
|
-
class
|
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
|
-
::
|
13
|
-
::ActionMailer::Base.send :include, ::Voltron::Translate
|
9
|
+
::String.send :include, ::Voltron::Translate
|
14
10
|
end
|
15
11
|
end
|
16
12
|
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.
|
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-
|
11
|
+
date: 2017-10-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|