From 5ed13d1539525e1ab097a1bf37e5d48b831799b4 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Thu, 7 Mar 2019 11:37:54 +1100 Subject: [PATCH] Fix translation by using ActiveRecord's default Our translations are not available when decorators are loaded. The message for a missing product category was missing: https://github.com/openfoodfoundation/openfoodnetwork/issues/1829 I moved the translation to ActiveRecord's default scope so that it can be picked up automatically. --- app/models/spree/product_decorator.rb | 2 +- config/locales/en.yml | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/models/spree/product_decorator.rb b/app/models/spree/product_decorator.rb index cade1d34d7..9de4a2a679 100644 --- a/app/models/spree/product_decorator.rb +++ b/app/models/spree/product_decorator.rb @@ -25,7 +25,7 @@ Spree::Product.class_eval do # validates_presence_of :variants, unless: :new_record?, message: "Product must have at least one variant" validates_presence_of :supplier - validates :primary_taxon, presence: { message: I18n.t("validation_msg_product_category_cant_be_blank") } + validates :primary_taxon, presence: true validates :tax_category_id, presence: { message: I18n.t("validation_msg_tax") }, if: "Spree::Config.products_require_tax_category" validates_presence_of :variant_unit diff --git a/config/locales/en.yml b/config/locales/en.yml index 3248089f88..108e1c868e 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -34,6 +34,8 @@ en: email: Customer E-Mail spree/payment: amount: Amount + spree/product: + primary_taxon: Product Category order_cycle: orders_close_at: Close date errors: @@ -2392,7 +2394,6 @@ See the %{link} to find out more about %{sitename}'s features and to start using enterprise_fee_by: "%{type} fee by %{role} %{enterprise_name}" validation_msg_relationship_already_established: "^That relationship is already established." validation_msg_at_least_one_hub: "^At least one hub must be selected" - validation_msg_product_category_cant_be_blank: "^Product Category cant be blank" validation_msg_tax: "^Tax Category is required" validation_msg_tax_category_cant_be_blank: "^Tax Category can't be blank" validation_msg_is_associated_with_an_exising_customer: "is associated with an existing customer"