MailingList


 « Return to Thread: Conitional translations

Conitional translations

by gobi :: Rate this Message:

Reply to Author | View in Thread

Dear all

I am trying to use Globalize2 and it works great. Thanks for great job.

I am trying to translate existing application and I had following problem.

I am translating such model.

# Table name: settings
#  ...
#  type      :string(20)  
#  value       :string(500)  

class  Settings < ActiveRecord::Base
  translates :value
  serialize :value
end

And I built following migration:

    create_table "settings", :force => true do |t|
      t.column "type",      :string,   :limit => 20
      t.timestamps
    end
   
    create_table "setting_translations", :force => true do |t|
      t.column "locale",        :string,   :limit =>10
      t.references :setting
      t.column "value",       :string,   :limit => 500
      t.timestamps
    end

The problem is value type depends on type property and I am saving none
string values in the database using yaml. But Globalize2 translates only
strings and in case of array it turns into nil.

So I do not want to translate in case none string types.

Is it possible that in case of none string type I do not translate it
and I want to save it only in English. Shortly depending on some
conditions I do not want translate it. How should I do it?

Thanks,
Sincerely Gobi.

 « Return to Thread: Conitional translations