Rails and model translations: Main language in original model, translations in external store?

162 views Asked by At

I'm digging around for a Rails model translation solution that fits my needs.

I have a model Page with fields title and content. I already have a lot of records in its table.

Now I want to translate both title and content. I'd like to keep the title and content fields in the pages table (holding the main language, English) and just add translations to an external store (e.g. German).

I checked out both globalize and mobility gem. But both of them seem to force me to move everything into the external store, so I need to delete the original title and content fields in the pages table.

Is this true? Is there any way to do it the way I'd like to have it? Maybe with another gem?

1

There are 1 answers

0
Fabrizio Bertoglio On

I don't have the answer to your problem, but I though of posting my comment hear.

Globalize will create a table for translations. You can do the same by yourself to create a table with translations for german and other languages. Still I believe your model will keep a pages table with the title and content field. Globalize was also not good for me so I decided to have my own implementation

This is from my schema.rb in my github project

  create_table "languages", force: :cascade do |t|
    t.string   "iso"
    t.string   "name"
    t.datetime "created_at", null: false
    t.datetime "updated_at", null: false
  end

Unluckily I don't find anymore the other models/tables, but I remember I created a table with a column for every translation required, then I would just display in my view the translation.