lundi 14 décembre 2015

Optionally translate strings using Globalize

Using

  • globalize3 0.3.0
  • Ruby 2.1.6
  • Rails 3.2.21

In the model MyModel I have two attributes that can be translated: name (required) and title (optional). I have the following settings in my model:

translates :name, required: true
translates :title

class Translation
  attr_accessible :title, :name
end

However, I am not able to save it. The following configuration works, although it is not what I want:

translates : title, :name
translates :title

class Translation
  attr_accessible :title, :name
end

How can I force :name to be translated, and optionally :title to be translated too?

Aucun commentaire:

Enregistrer un commentaire