views:

11

answers:

1

Could you tell me how to add internationalization for select tags in formtastic?

# view
....
f.input :hair_colour,  :as => :select,       :collection => HAIR_COLOURS
....

# user.rb
class User << AR
  validates_inclusion_of :hair_colour, :in => [0..8]
end

# de.yml
de:
  profile:
    hair_colour:
      0: "Blond"
      1: "Dunkelblond"
      2: "Braun"
      3: "Brünett"
      4: "Rot"
      5: "Schwarz"
      6: "Grau/meliert"
      7: "Glatze"
      8: "Andere"

# constants.rb
HAIR_COLOURS = {:blond => 0, :light_brown => 1, :brown => 2, 
  :brunette => 3, :red => 4, :black => 5, :gray => 6, :bald_head => 7, 
  :other_colour => 8}

Thx!