Class: Globalize::Automatic::Translator
- Inherits:
-
Object
- Object
- Globalize::Automatic::Translator
- Defined in:
- lib/globalize/automatic/translator.rb
Direct Known Subclasses
Defined Under Namespace
Classes: EasyTranslate
Instance Method Summary collapse
- #after_translate(text, from, to, result) ⇒ Object
- #before_translate(text, from, to) ⇒ Object
- #run(automatic_translation, attr_name) ⇒ Object
- #translate(text, from, to) ⇒ Object
Instance Method Details
#after_translate(text, from, to, result) ⇒ Object
22 23 24 |
# File 'lib/globalize/automatic/translator.rb', line 22 def after_translate(text, from, to, result) [text, from, to, result] end |
#before_translate(text, from, to) ⇒ Object
18 19 20 |
# File 'lib/globalize/automatic/translator.rb', line 18 def before_translate(text, from, to) [text, from, to] end |
#run(automatic_translation, attr_name) ⇒ Object
5 6 7 8 9 10 11 12 13 14 |
# File 'lib/globalize/automatic/translator.rb', line 5 def run(automatic_translation, attr_name) translation = automatic_translation.translation_from(attr_name) text = translation[attr_name] from = translation.locale to = automatic_translation.locale _text, _from, _to = before_translate(text, from, to) translated = translate(_text, _from, _to) _text, _from, _to, _translated = after_translate(_text, _from, _to, translated) automatic_translation.resolve(attr_name, _translated) end |
#translate(text, from, to) ⇒ Object
16 |
# File 'lib/globalize/automatic/translator.rb', line 16 def translate(text, from, to); end |