From b249edeb404a3b3e58871aa11fe2eded4ccb2bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Tue, 17 Dec 2024 17:46:00 +0100 Subject: [PATCH] ecoscore / environmental score --- lib/ProductOpener/Attributes.pm | 11 ++++++++-- lib/ProductOpener/Config_off.pm | 11 ++++++---- lib/ProductOpener/EnvironmentalScore.pm | 7 ++++++ po/common/common.pot | 29 +++++++++++++++++++++++++ po/common/en.po | 29 +++++++++++++++++++++++++ po/common/fr.po | 29 +++++++++++++++++++++++++ po/tags/en.po | 12 +++++----- po/tags/hu.po | 4 ++-- po/tags/tags.pot | 4 ++-- 9 files changed, 120 insertions(+), 16 deletions(-) diff --git a/lib/ProductOpener/Attributes.pm b/lib/ProductOpener/Attributes.pm index 2ee2ba21f3fe8..7b72d53a2b895 100644 --- a/lib/ProductOpener/Attributes.pm +++ b/lib/ProductOpener/Attributes.pm @@ -281,7 +281,7 @@ sub initialize_attribute ($attribute_id, $target_lc) { $attribute_ref->{icon_url} = "$static_subdomain/images/attributes/dist/nutriscore-a.svg"; $attribute_ref->{panel_id} = "nutriscore"; } - elsif ($attribute_id eq "environmental_score") { + elsif ($attribute_id eq "ecoscore") { $attribute_ref->{icon_url} = "$static_subdomain/images/attributes/dist/ecoscore-a.svg"; $attribute_ref->{panel_id} = "environmental_score"; } @@ -616,6 +616,10 @@ sub compute_attribute_nutriscore ($product_ref, $target_lc, $target_cc) { Computes an environmental impact attribute based on the Environmental-Score. +Note: before 2025, the Environmental-Score was called the Eco-Score, +as the id of the attribute is stored inside clients, we keep the +id "ecoscore" for the attribute. + =head3 Arguments =head4 product reference $product_ref @@ -648,7 +652,10 @@ sub compute_attribute_environmental_score ($product_ref, $target_lc, $target_cc) {code => $product_ref->{code}, environmental_score_data => $product_ref->{environmental_score_data}}) if $log->is_debug(); - my $attribute_id = "environmental_score"; + # Note: before 2025, the Environmental-Score was called the Eco-Score, + # as the id of the attribute is stored inside clients, we keep the + # id "ecoscore" for the attribute. + my $attribute_id = "ecoscore"; my $attribute_ref = initialize_attribute($attribute_id, $target_lc); diff --git a/lib/ProductOpener/Config_off.pm b/lib/ProductOpener/Config_off.pm index 2bc28bcb716b0..53a0330c73cc4 100644 --- a/lib/ProductOpener/Config_off.pm +++ b/lib/ProductOpener/Config_off.pm @@ -712,7 +712,7 @@ $options{replace_existing_values_when_importing_those_tags_fields} = { ); # tag types (=facets) that should be indexed by web crawlers, all other tag types are not indexable -@index_tag_types = qw(brands categories labels additives nova_groups environmental_score nutrition_grades products); +@index_tag_types = qw(brands categories labels additives nova_groups ecoscore nutrition_grades products); # fields in product edit form, above ingredients and nutrition facts @@ -794,7 +794,7 @@ $options{replace_existing_values_when_importing_those_tags_fields} = { @drilldown_fields = qw( nutrition_grades nova_groups - environmental_score + ecoscore brands categories labels @@ -965,7 +965,10 @@ $options{attribute_groups} = [ ], ["ingredients_analysis", ["vegan", "vegetarian", "palm_oil_free",]], ["labels", ["labels_organic", "labels_fair_trade"]], - ["environment", ["environmental_score", "forest_footprint",]], + # Note: before 2025, the Environmental-Score was called the Eco-Score, + # as the id of the attribute is stored inside clients, we keep the + # id "ecoscore" for the attribute. + ["environment", ["ecoscore", "forest_footprint",]], ]; # By default attributes have 4 possible values: not_important, important, very_important, mandatory @@ -995,7 +998,7 @@ $options{attribute_values} = { $options{attribute_default_preferences} = { "nutriscore" => "very_important", "nova" => "important", - "environmental_score" => "important", + "ecoscore" => "important", }; use JSON::MaybeXS; diff --git a/lib/ProductOpener/EnvironmentalScore.pm b/lib/ProductOpener/EnvironmentalScore.pm index 33bed1bf16b0a..4541600992c5d 100644 --- a/lib/ProductOpener/EnvironmentalScore.pm +++ b/lib/ProductOpener/EnvironmentalScore.pm @@ -1008,6 +1008,13 @@ sub compute_environmental_score ($product_ref) { } } + # Before 2025, the Environmental Score was called the Eco-Score. + # to ease the transition, we copy environmental_score_tags to eco_score_tags + # so that queries to MongoDB and off-query do not have to change + if (defined $product_ref->{environmental_score_tags}) { + $product_ref->{ecoscore_tags} = $product_ref->{environmental_score_tags}; + } + return; } diff --git a/po/common/common.pot b/po/common/common.pot index 2a4c0c720b1ad..9ce4efc698e00 100644 --- a/po/common/common.pot +++ b/po/common/common.pot @@ -4820,6 +4820,19 @@ msgctxt "attribute_environmental_score_setting_note" msgid "The Eco-Score is an environmental score from A to E which makes it easy to compare the impact of food products on the environment." msgstr "" +# Note: the Eco-Score is renamed to Environmental Score, but we keep the ecoscore identifier as it is stored in clients +msgctxt "attribute_ecoscore_name" +msgid "Eco-Score" +msgstr "Eco-Score" + +msgctxt "attribute_ecoscore_setting_name" +msgid "Low environmental impact (Eco-Score)" +msgstr "Low environmental impact (Eco-Score)" + +msgctxt "attribute_ecoscore_setting_note" +msgid "The Eco-Score is an environmental score from A to E which makes it easy to compare the impact of food products on the environment." +msgstr "The Eco-Score is an environmental score from A to E which makes it easy to compare the impact of food products on the environment." + # keep %s, it will be replaced by the letter A+, A, B, C, D, E or F msgctxt "attribute_environmental_score_grade_title" msgid "Eco-Score %s" @@ -5051,6 +5064,14 @@ msgctxt "missing_nutrition_facts" msgid "Missing nutrition facts" msgstr "Missing nutrition facts" +msgctxt "ecoscore_p" +msgid "Eco-Score" +msgstr "Eco-Score" + +msgctxt "ecoscore_s" +msgid "Eco-Score" +msgstr "Eco-Score" + msgctxt "environmental_score_p" msgid "Eco-Score" msgstr "Eco-Score" @@ -5059,6 +5080,14 @@ msgctxt "environmental_score_s" msgid "Eco-Score" msgstr "Eco-Score" +msgctxt "misc_p" +msgid "Miscellaneous" +msgstr "Miscellaneous" + +msgctxt "misc_s" +msgid "Miscellaneous" +msgstr "Miscellaneous" + msgctxt "packaging_parts" msgid "Packaging parts" msgstr "Packaging parts" diff --git a/po/common/en.po b/po/common/en.po index 543988c122a22..bf094e69944cd 100644 --- a/po/common/en.po +++ b/po/common/en.po @@ -4839,6 +4839,19 @@ msgctxt "attribute_environmental_score_setting_note" msgid "The Eco-Score is an environmental score from A to E which makes it easy to compare the impact of food products on the environment." msgstr "The Eco-Score is an environmental score from A to E which makes it easy to compare the impact of food products on the environment." +# Note: the Eco-Score is renamed to Environmental Score, but we keep the ecoscore identifier as it is stored in clients +msgctxt "attribute_ecoscore_name" +msgid "Eco-Score" +msgstr "Eco-Score" + +msgctxt "attribute_ecoscore_setting_name" +msgid "Low environmental impact (Eco-Score)" +msgstr "Low environmental impact (Eco-Score)" + +msgctxt "attribute_ecoscore_setting_note" +msgid "The Eco-Score is an environmental score from A to E which makes it easy to compare the impact of food products on the environment." +msgstr "The Eco-Score is an environmental score from A to E which makes it easy to compare the impact of food products on the environment." + # keep %s, it will be replaced by the letter A+, A, B, C, D, E or F msgctxt "attribute_environmental_score_grade_title" msgid "Eco-Score %s" @@ -5070,6 +5083,14 @@ msgctxt "missing_nutrition_facts" msgid "Missing nutrition facts" msgstr "Missing nutrition facts" +msgctxt "ecoscore_p" +msgid "Eco-Score" +msgstr "Eco-Score" + +msgctxt "ecoscore_s" +msgid "Eco-Score" +msgstr "Eco-Score" + msgctxt "environmental_score_p" msgid "Eco-Score" msgstr "Eco-Score" @@ -5078,6 +5099,14 @@ msgctxt "environmental_score_s" msgid "Eco-Score" msgstr "Eco-Score" +msgctxt "misc_p" +msgid "Miscellaneous" +msgstr "Miscellaneous" + +msgctxt "misc_s" +msgid "Miscellaneous" +msgstr "Miscellaneous" + msgctxt "packaging_parts" msgid "Packaging parts" msgstr "Packaging parts" diff --git a/po/common/fr.po b/po/common/fr.po index 3282a0091693d..9396652fe5117 100644 --- a/po/common/fr.po +++ b/po/common/fr.po @@ -4838,6 +4838,19 @@ msgctxt "attribute_environmental_score_setting_note" msgid "The Eco-Score is an environmental score (environmental_score) from A to E which makes it easy to compare the impact of food products on the environment." msgstr "L'Eco-Score est un score environnemental (écoscore) de A à E qui permet de comparer facilement l'impact des produits alimentaires sur l'environnement." +# Note: the Eco-Score is renamed to Environmental Score, but we keep the ecoscore identifier as it is stored in clients +msgctxt "attribute_ecoscore_name" +msgid "Eco-Score" +msgstr "Eco-Score" + +msgctxt "attribute_ecoscore_setting_name" +msgid "Low environmental impact (Eco-Score)" +msgstr "Faible impact environnemental (Eco-Score)" + +msgctxt "attribute_ecoscore_setting_note" +msgid "The Eco-Score is an environmental score from A to E which makes it easy to compare the impact of food products on the environment." +msgstr "L'Eco-Score est un score environnemental (écoscore) de A à E qui permet de comparer facilement l'impact des produits alimentaires sur l'environnement." + # keep %s, it will be replaced by the letter A+, A, B, C, D, E or F msgctxt "attribute_environmental_score_grade_title" msgid "Eco-Score %s" @@ -5069,6 +5082,14 @@ msgctxt "missing_nutrition_facts" msgid "Missing nutrition facts" msgstr "Données nutritionnelles manquantes" +msgctxt "ecoscore_p" +msgid "Eco-Score" +msgstr "Eco-Score" + +msgctxt "ecoscore_s" +msgid "Eco-Score" +msgstr "Eco-Score" + msgctxt "environmental_score_p" msgid "Eco-Score" msgstr "Eco-Score" @@ -5077,6 +5098,14 @@ msgctxt "environmental_score_s" msgid "Eco-Score" msgstr "Eco-Score" +msgctxt "misc_p" +msgid "Miscellaneous" +msgstr "Divers" + +msgctxt "misc_s" +msgid "Miscellaneous" +msgstr "Divers" + msgctxt "packaging_parts" msgid "Packaging parts" msgstr "Elements d'emballage" diff --git a/po/tags/en.po b/po/tags/en.po index 05eaec9881729..825c6fffe6856 100644 --- a/po/tags/en.po +++ b/po/tags/en.po @@ -542,13 +542,13 @@ msgctxt "owners:singular" msgid "owner" msgstr "owner" -msgctxt "environmental_score:plural" -msgid "eco-score" -msgstr "eco-score" +msgctxt "ecoscore:plural" +msgid "environmental-score" +msgstr "environmental-score" -msgctxt "environmental_score:singular" -msgid "eco-score" -msgstr "eco-score" +msgctxt "ecoscore:singular" +msgid "environmental-score" +msgstr "environmental-score" msgctxt "food_groups:plural" msgid "food-groups" diff --git a/po/tags/hu.po b/po/tags/hu.po index 6faa01c86ed63..55be3e9df4ab5 100644 --- a/po/tags/hu.po +++ b/po/tags/hu.po @@ -633,10 +633,10 @@ msgctxt "owners:singular" msgid "owner" msgstr "tulajdonos" -msgctxt "environmental_score:plural" +msgctxt "ecoscore:plural" msgid "environmental_score" msgstr "environmental_score" -msgctxt "environmental_score:singular" +msgctxt "ecoscore:singular" msgid "environmental_score" msgstr "environmental_score" diff --git a/po/tags/tags.pot b/po/tags/tags.pot index 8f6bd9af4e3f2..06cd179e97f02 100644 --- a/po/tags/tags.pot +++ b/po/tags/tags.pot @@ -638,11 +638,11 @@ msgctxt "owners:singular" msgid "owner" msgstr "owner" -msgctxt "environmental_score:plural" +msgctxt "ecoscore:plural" msgid "environmental_score" msgstr "environmental_score" -msgctxt "environmental_score:singular" +msgctxt "ecoscore:singular" msgid "environmental_score" msgstr "environmental_score"