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
23 24 25 |
# File 'lib/globalize/automatic/translator.rb', line 23 def after_translate(text, from, to, result) [text, from, to, result] end |
#before_translate(text, from, to) ⇒ Object
19 20 21 |
# File 'lib/globalize/automatic/translator.rb', line 19 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 15 |
# File 'lib/globalize/automatic/translator.rb', line 5 def run(automatic_translation, attr_name) attr_name = attr_name.to_sym 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
17 |
# File 'lib/globalize/automatic/translator.rb', line 17 def translate(text, from, to); end |