[internationalization] Multiple strings in one DB field


#1

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

  1. One db field per locale (caption_fr, caption_en) but :
  • Need to alter the DB structure when adding new locales
  1. 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