Forum: Ruby on Rails [internationalization] Multiple strings in one DB field

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
9c0eebc506c56c64dc616cdf123fa671?d=identicon&s=25 Chris Chris (aboulafia)
on 2008-10-06 11:04
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
This topic is locked and can not be replied to.