Browse files

Changed scope for "taken" error message translation to decrease prece…

…dence

Moved activerecord.errors.messages.taken to errors.messages.taken so that translations for, e.g., errors.attributes.email.taken don't get overridden.

Test that the translation for 'taken' can be overridden
  • Loading branch information...
1 parent 2268859 commit f48b7cc053a991404f973ca59dfede87ff6492db @adimichele adimichele committed Oct 19, 2012
View
6 activerecord/lib/active_record/locale/en.yml
@@ -4,11 +4,15 @@ en:
#created_at: "Created at"
#updated_at: "Updated at"
+ # Default error messages
+ errors:
+ messages:
+ taken: "has already been taken"
+
# Active Record models configuration
activerecord:
errors:
messages:
- taken: "has already been taken"
record_invalid: "Validation failed: %{errors}"
restrict_dependent_destroy:
one: "Cannot delete record because a dependent %{record} exists"
View
5 activerecord/test/cases/validations/i18n_generate_message_validation_test.rb
@@ -54,4 +54,9 @@ def test_generate_message_taken_with_custom_message
end
end
+ test "translation for 'taken' can be overridden" do
+ I18n.backend.store_translations "en", {errors: {attributes: {title: {taken: "Custom taken message" }}}}
+ assert_equal "Custom taken message", @topic.errors.generate_message(:title, :taken, :value => 'title')
+ end
+
end

0 comments on commit f48b7cc

Please sign in to comment.