Mat Schaffer on 28 Feb 2007 16:50:39 -0000


[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]

Re: [PhillyOnRails] Thanks! And topic idea.


On Feb 28, 2007, at 11:26 AM, Mark Chadwick wrote:
I recently wrote a acts_as_translatable plugin. It meshes well with Globalize (or similar). The idea is to have translatable fields on models where it doesn't really fit in to pre-translated strings. For example:

I have a product that asks users questions. The questions are in the DB, and users can make their own questions. I want the same questions to be asked to everyone, but I want it to be the the correct language, so:

class Question < AR::Base
  acts_as_translatable [:title, :body]
end

And in the migration:
Question.create_translated_tables

That way, when I have a Question, and I do <%= question.body %>, It's going to check with Globalize, see what the current language is, and display the correct translation.

Well. That was quite a spiel. Anyone want to see a presentation on that?

So this works in conjunction with Globalize? It seems like the same functionality as the function 'translates' that globalize adds to AR::Base. So:


class Question < AR::Base
  translates :title, :body
end

The only difference I see is the migration, where globalize uses the master translation table to store the translated text. Is this option more efficient perhaps?
-Mat



_______________________________________________ To unsubscribe or change your settings, visit: http://lists.phillyonrails.org/mailman/listinfo/talk