Christophe Gimenez
2008-Oct-06 09:04 UTC
[internationalization] Multiple strings in one DB field
Hello, I''m trying to find the best solution to handle DB localized
datas
and I don''t want to use a plugin for database fields translation.
1) Serializing a hash using the locale as a key.
Eg. caption field in table categories could contain
{:fr => ''Livres'', :en => ''Books''}
Using serialization I''ll will be able to do rails find or SQL find
LIKE.
The only drawback I see is when editing the category : the view must
generate dynamically the input fields depending on the content and name
them accordingly (caption_fr, caption_en) - I don''t know if it will
cause me a lot of troubles in regard of the validation rules
(validate_format with the right regex pattern could do the trick)
I really want to avoid the full blow internationalization plugins
2) One db field per locale (caption_fr, caption_en) but :
- Need to alter the DB structure when adding new locales
3) Caption field contains an ID, (ID of a string resource) with a join
to the resources table. The caption corresponding to the current locale
is retrieved on the view with some application helpers
- Added complexity in forms and controllers when editing records
Any thought, advice or alternative solution about this idea ?
Thanks
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---