In this third article in a four-part series on adding support for multiple languages to a Ruby-on-Rails ecomerce application, you will learn how to add a translation to a site, edit the translation, and more. This article is excerpted from chapter 10 of the book Practical Rails Projects, written by Eldon Alameda (Apress; ISBN: 1590597818).
Translating a Site for Multiple Language Support - Implementing the Edit Translation User Story (Page 2 of 5 )
The in-place editor uses two actions that are called through Ajax requests: get_translation_text and set_translation_text . Next, add these two actions to the controller ( app/controllers/ admin/translate_controller.rb ):
The get action is called to retrieve and show the translation for the current record, when the administrator clicks somewhere inside the in-place editor field (in the translation column). The set action is called when the administrator saves the translation by clicking the OK button.
Now clicking the translated text in the translation column opens an in-place editor, which allows you to edit the translation, as shown in Figure 10-5. You can save the changes by clicking the OK button, or cancel them by clicking the Cancel button. You can even open more than one in-place editor at a time.