I''m trying to implement internationalization in my app. I followed the instructions on the Globalize example (http://wiki.globalize- rails.org/globalize/show/Example+Application), using in_place_editor. The translation works fine, however, I can''t get in_place_editor to work to translate the strings. My controller: class Admin::TranslateController < ApplicationController in_place_edit_for :translation, :text def index @view_translations = ViewTranslation.find(:all, :conditions => [ ''built_in IS NULL AND language_id = ?'', Locale.language.id ], :order => ''text'') end def translation_text @translation = ViewTranslation.find(params[:id]) render :text => @translation.text || "" end def set_translation_text @translation = ViewTranslation.find(params[:id]) previous = @translation.text @translation.text = params[:value] @translation.text = previous unless @translation.save render :partial => "translation_text", :object => @translation.text end end And the call in view: <%= in_place_editor "tr_#{tr.id}", :url => { :action => :set_translation_text, :id => tr.id }, :load_text_url => url_for({ :action => :translation_text, :id => tr.id })%> </p> It loads the value that it gets from translation_text, but when I try to change the string, all it says in the box is ''Saving...'' and it never updates the entry. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Frederick Cheung
2007-Dec-21 22:23 UTC
Re: in_place_editor not working for Internationalization
On 21 Dec 2007, at 01:47, Franz wrote:> > I''m trying to implement internationalization in my app. I followed > the instructions on the Globalize example (http://wiki.globalize- > rails.org/globalize/show/Example+Application), using in_place_editor. > The translation works fine, however, I can''t get in_place_editor to > work to translate the strings.If your app is a rails 2.0 app, in_place_editor currently doesn''t work with crsf. Fred> > > My controller: > > class Admin::TranslateController < ApplicationController > in_place_edit_for :translation, :text > > def index > @view_translations = ViewTranslation.find(:all, :conditions => > [ ''built_in IS NULL AND language_id = ?'', Locale.language.id ], :order > => ''text'') > end > > def translation_text > @translation = ViewTranslation.find(params[:id]) > render :text => @translation.text || "" > end > > def set_translation_text > @translation = ViewTranslation.find(params[:id]) > previous = @translation.text > @translation.text = params[:value] > @translation.text = previous unless @translation.save > render :partial => "translation_text", :object => > @translation.text > end > end > > And the call in view: > > <%= in_place_editor "tr_#{tr.id}", > :url => { :action => :set_translation_text, :id => tr.id }, > :load_text_url => url_for({ :action => :translation_text, :id => > tr.id })%> > </p> > > It loads the value that it gets from translation_text, but when I try > to change the string, all it says in the box is ''Saving...'' and it > never updates the entry. > >--~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---