Module: Voltron::Translate
- Defined in:
- lib/voltron/translate.rb,
lib/voltron/translate/engine.rb,
lib/voltron/translate/version.rb,
lib/generators/voltron/translate/install_generator.rb
Defined Under Namespace
Modules: Generators
Classes: Engine, InvalidColumnTypeError, Translator
Constant Summary
collapse
- LOG_COLOR =
:light_blue
- VERSION =
'0.2.3'.freeze
Instance Method Summary
collapse
Instance Method Details
#_(locale = I18n.locale, **args) ⇒ Object
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
|
# File 'lib/voltron/translate.rb', line 17
def _(locale = I18n.locale, **args)
return (self % args) if !Voltron.config.translate.enabled? || self.blank?
begin
raise 'Locale can only contain the characters A-Z, and _' unless locale.to_s =~ /^[A-Z_]+$/i
if Voltron.config.translate.buildable?
Array.wrap(Voltron.config.translate.locales).compact.each { |locale| translator(locale).write self }
end
translator(locale).translate self, **args
rescue => e
Voltron.log e.message.to_s + " (Original Translation Text: #{self})", 'Translate', ::Voltron::Translate::LOG_COLOR
self % args
end
end
|
#translator(locale = I18n.locale) ⇒ Object
37
38
39
40
|
# File 'lib/voltron/translate.rb', line 37
def translator(locale = I18n.locale)
@translators ||= {}
@translators[locale.to_s] ||= Translator.new(locale)
end
|