From a716713ed6f95a8b4b6db77899530c4e97792990 Mon Sep 17 00:00:00 2001 From: Pierre de La Morinerie Date: Tue, 24 Mar 2020 14:28:21 +0000 Subject: [PATCH] locales: fix translation of champ value Due to the extra 's', the names of Champs attributes were never translated. --- app/models/champs/decimal_number_champ.rb | 4 ++-- app/models/champs/integer_number_champ.rb | 4 ++-- config/locales/models/champs/fr.yml | 2 +- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/models/champs/decimal_number_champ.rb b/app/models/champs/decimal_number_champ.rb index d7063cf8e..31278e52a 100644 --- a/app/models/champs/decimal_number_champ.rb +++ b/app/models/champs/decimal_number_champ.rb @@ -2,8 +2,8 @@ class Champs::DecimalNumberChamp < Champ validates :value, numericality: { allow_nil: true, allow_blank: true, - message: -> (object, data) { - "« #{object.libelle} » " + object.errors.generate_message(data[:attribute].downcase, :not_a_number) + message: -> (object, _data) { + "« #{object.libelle} » " + object.errors.generate_message(:value, :not_a_number) } } diff --git a/app/models/champs/integer_number_champ.rb b/app/models/champs/integer_number_champ.rb index c2c0ea254..082c73593 100644 --- a/app/models/champs/integer_number_champ.rb +++ b/app/models/champs/integer_number_champ.rb @@ -3,8 +3,8 @@ class Champs::IntegerNumberChamp < Champ only_integer: true, allow_nil: true, allow_blank: true, - message: -> (object, data) { - "« #{object.libelle} » " + object.errors.generate_message(data[:attribute].downcase, :not_an_integer) + message: -> (object, _data) { + "« #{object.libelle} » " + object.errors.generate_message(:value, :not_an_integer) } } diff --git a/config/locales/models/champs/fr.yml b/config/locales/models/champs/fr.yml index d1ab85d27..9d9e6b2f0 100644 --- a/config/locales/models/champs/fr.yml +++ b/config/locales/models/champs/fr.yml @@ -1,5 +1,5 @@ fr: activerecord: attributes: - champs: + champ: value: La valeur du champ