Skip to content
Browse files

translation for OptionValue#presentation

  • Loading branch information...
1 parent 806d830 commit b89d9924ac270d7574737c94f1d52dfa634f2a2a @oliverbarnes oliverbarnes committed Jul 1, 2010
View
2 db/migrate/20090824173314_add_translation_tables.rb
@@ -6,6 +6,7 @@ def self.up
Taxonomy.create_translation_table! :name => :string
Taxon.create_translation_table! :name => :string
OptionType.create_translation_table! :presentation => :string
+ OptionValue.create_translation_table! :presentation => :string
end
def self.down
@@ -15,5 +16,6 @@ def self.down
Taxonomy.drop_translation_table!
Taxon.drop_translation_table!
OptionType.drop_translation_table!
+ OptionValue.drop_translation_table!
end
end
View
6 lib/tasks/product_translations_extension_tasks.rake
@@ -76,6 +76,12 @@ namespace :spree do
p.save!
end
puts "done."
+
+ OptionValue.all.each do |p|
+ p.presentation = fetch_first_row("select option_values.presentation from option_values where option_values.id=#{p.id}")
+ p.save!
+ end
+ puts "done."
end
end
end
View
4 product_translations_extension.rb
@@ -32,5 +32,9 @@ def activate
translates :presentation
end
+ OptionValue.class_eval do
+ translates :presentation
+ end
+
end
end
View
21 test/unit/option_value_test.rb
@@ -0,0 +1,21 @@
+require File.expand_path(File.dirname(__FILE__) + '/../test_helper')
+
+class OptionValueTranslationTest < Test::Unit::TestCase
+
+ context 'option value translations' do
+ setup do
+ I18n.locale = 'en-US'
+ @option_value = Factory(:option_value, :presentation => 'english presentation')
+ I18n.locale = 'pt-BR'
+ @option_value.presentation = 'apresentação em português'
+ @option_value.save!
+ end
+
+ should "translate the presentation" do
+ I18n.locale = 'en-US'
+ assert_equal 'english presentation', @option_value.presentation
+ I18n.locale = 'pt-BR'
+ assert_equal 'apresentação em português', @option_value.presentation
+ end
+ end
+end

0 comments on commit b89d992

Please sign in to comment.
Something went wrong with that request. Please try again.