Skip to content

Commit

Permalink
feat: launch new Nutri-Score for France (#11123)
Browse files Browse the repository at this point in the history
This PR removes the display of the old Nutri-Score and displays the new
Nutri-Score for all products.

For moderators and on the pro platform, we also display the old
Nutri-Score below the new one.

The PR also adds a panel to briefly list the main improvements, which
links to /new-nutri-score (which will be the new address for the
https://world.openfoodfacts.org/nutriscore-v2 page)


![image](https://github.com/user-attachments/assets/f4f8a425-0ef4-4cc1-9876-5479e9ae887f)



![image](https://github.com/user-attachments/assets/027da72b-9b31-413c-adc6-5d7197dbd461)

---------

Co-authored-by: Open Food Facts Bot <contact@openfoodfacts.org>
  • Loading branch information
stephanegigandet and Open Food Facts Bot authored Dec 16, 2024
1 parent f47fddf commit e1a7800
Show file tree
Hide file tree
Showing 34 changed files with 2,449 additions and 216 deletions.
5 changes: 1 addition & 4 deletions lib/ProductOpener/Attributes.pm
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ This parameter sets the desired language for the user facing strings.
=head4 country code $target_cc
Different countries can have different versions of the Nutri-Score at a given time.
e.g. in early 2024, France does not use the new Nutri-Score 2023 yet, while other countries do.
e.g. in early 2024, France did not use the new Nutri-Score 2023 yet, while other countries did.
=head3 Return value
Expand All @@ -459,9 +459,6 @@ that is used to define the Nutri-Score grade from A to E.
sub compute_attribute_nutriscore ($product_ref, $target_lc, $target_cc) {

my $version = "2023";
if ($target_cc eq "fr") {
$version = "2021";
}

$log->debug("compute nutriscore attribute",
{code => $product_ref->{code}, version => $version, nutriscore => $product_ref->{nutriscore}{$version}})
Expand Down
21 changes: 12 additions & 9 deletions lib/ProductOpener/KnowledgePanels.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1030,20 +1030,18 @@ sub create_health_card_panel ($product_ref, $target_lc, $target_cc, $options_ref
create_nova_panel($product_ref, $target_lc, $target_cc, $options_ref);
}
if (feature_enabled("nutriscore")) {
if ( $target_cc eq "fr"
|| $options_ref->{admin}

# For moderators, admins, and on the producers platform: we show the old Nutri-Score
# in addition to the new Nutri-Score

if ( $options_ref->{admin}
|| $options_ref->{moderator}
|| $options_ref->{producers_platform})
{
create_nutriscore_panel($product_ref, $target_lc, $target_cc, $options_ref);
}
if ( $target_cc ne "fr"
|| $options_ref->{admin}
|| $options_ref->{moderator}
|| $options_ref->{producers_platform})
{
create_nutriscore_2023_panel($product_ref, $target_lc, $target_cc, $options_ref);
}

create_nutriscore_2023_panel($product_ref, $target_lc, $target_cc, $options_ref);

create_nutrient_levels_panels($product_ref, $target_lc, $target_cc, $options_ref);

Expand Down Expand Up @@ -1207,6 +1205,11 @@ sub create_nutriscore_2023_panel ($product_ref, $target_lc, $target_cc, $options
create_panel_from_json_template("nutriscore_2023", "api/knowledge-panels/health/nutriscore/nutriscore_2023.tt.json",
$panel_data_ref, $product_ref, $target_lc, $target_cc, $options_ref);

# Nutri-Score new computation
create_panel_from_json_template("nutriscore_new_computation",
"api/knowledge-panels/health/nutriscore/nutriscore_new_computation.tt.json",
$panel_data_ref, $product_ref, $target_lc, $target_cc, $options_ref);

# Nutri-Score description
create_panel_from_json_template("nutriscore_description",
"api/knowledge-panels/health/nutriscore/nutriscore_description.tt.json",
Expand Down
28 changes: 28 additions & 0 deletions po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6862,6 +6862,34 @@ msgctxt "nutriscore_count_proteins_reason_negative_points_greater_than_or_equal_
msgid "Points for proteins are not counted because the negative points greater than or equal to 11."
msgstr ""

msgctxt "nutriscore_new_computation_title"
msgid "Discover the new Nutri-Score!"
msgstr "Discover the new Nutri-Score!"

msgctxt "nutriscore_new_computation_description"
msgid "<p>The computation of the Nutri-Score is evolving to provide better recommendations based on the latest scientific evidence.</p>"
"<p>Main improvements:</p>"
"<ul>"
"<li>Better differentiation of milks, sweetened dairy drinks and plant-based drinks</li>"
"<li>Better ranking of drinks to favor low-sugar drinks without sweeteners</li>"
"<li>Lower grades for products that contain too much salt or sugar</li>"
"<li>Higher grades for some fatty fish and oils rich in good fats</li>"
"<li>Lower grades for red meat</li>"
"</ul>"
msgstr "<p>The computation of the Nutri-Score is evolving to provide better recommendations based on the latest scientific evidence.</p>"
"<p>Main improvements:</p>"
"<ul>"
"<li>Better differentiation of milks, sweetened dairy drinks and plant-based drinks</li>"
"<li>Better ranking of drinks to favor low-sugar drinks without sweeteners</li>"
"<li>Lower grades for products that contain too much salt or sugar</li>"
"<li>Higher grades for some fatty fish and oils rich in good fats</li>"
"<li>Lower grades for red meat</li>"
"</ul>"

msgctxt "nutriscore_new_computation_link_text"
msgid "Discover all the improvements of the new Nutri-Score"
msgstr "Discover all the improvements of the new Nutri-Score"

msgctxt "nutriscore_explanation_what_it_is"
msgid "The Nutri-Score is a logo on the overall nutritional quality of products."
msgstr "The Nutri-Score is a logo on the overall nutritional quality of products."
Expand Down
28 changes: 28 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -6881,6 +6881,34 @@ msgctxt "nutriscore_count_proteins_reason_negative_points_greater_than_or_equal_
msgid "Points for proteins are not counted because the negative points greater than or equal to 11."
msgstr "Points for proteins are not counted because the negative points greater than or equal to 11."

msgctxt "nutriscore_new_computation_title"
msgid "Discover the new Nutri-Score!"
msgstr "Discover the new Nutri-Score!"

msgctxt "nutriscore_new_computation_description"
msgid "<p>The computation of the Nutri-Score is evolving to provide better recommendations based on the latest scientific evidence.</p>"
"<p>Main improvements:</p>"
"<ul>"
"<li>Better differentiation of milks, sweetened dairy drinks and plant-based drinks</li>"
"<li>Better ranking of drinks to favor low-sugar drinks without sweeteners</li>"
"<li>Lower grades for products that contain too much salt or sugar</li>"
"<li>Higher grades for some fatty fish and oils rich in good fats</li>"
"<li>Lower grades for red meat</li>"
"</ul>"
msgstr "<p>The computation of the Nutri-Score is evolving to provide better recommendations based on the latest scientific evidence.</p>"
"<p>Main improvements:</p>"
"<ul>"
"<li>Better differentiation of milks, sweetened dairy drinks and plant-based drinks</li>"
"<li>Better ranking of drinks to favor low-sugar drinks without sweeteners</li>"
"<li>Lower grades for products that contain too much salt or sugar</li>"
"<li>Higher grades for some fatty fish and oils rich in good fats</li>"
"<li>Lower grades for red meat</li>"
"</ul>"

msgctxt "nutriscore_new_computation_link_text"
msgid "Discover all the improvements of the new Nutri-Score"
msgstr "Discover all the improvements of the new Nutri-Score"

msgctxt "nutriscore_explanation_what_it_is"
msgid "The Nutri-Score is a logo on the overall nutritional quality of products."
msgstr "The Nutri-Score is a logo on the overall nutritional quality of products."
Expand Down
28 changes: 28 additions & 0 deletions po/common/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -6868,6 +6868,34 @@ msgctxt "nutriscore_count_proteins_reason_negative_points_greater_than_or_equal_
msgid "Points for proteins are not counted because the negative points greater than or equal to 11."
msgstr "Les points pour les protéines ne sont pas comptés car les points négatifs sont supérieurs ou égaux à 11."

msgctxt "nutriscore_new_computation_title"
msgid "Discover the new Nutri-Score!"
msgstr "Découvrez le nouveau Nutri-Score !"

msgctxt "nutriscore_new_computation_description"
msgid "<p>The computation of the Nutri-Score is evolving to provide better recommendations based on the latest scientific evidence.</p>"
"<p>Main improvements:</p>"
"<ul>"
"<li>Better differentiation of milks, sweetened dairy drinks and plant-based drinks</li>"
"<li>Better ranking of drinks to favor low-sugar drinks without sweeteners</li>"
"<li>Lower grades for products that contain too much salt or sugar</li>"
"<li>Higher grades for some fatty fish and oils rich in good fats</li>"
"<li>Lower grades for red meat</li>"
"</ul>"
msgstr "<p>Le calcul du Nutri-Score évolue pour fournir de meilleures recommandations basées sur les dernières preuves scientifiques.</p>"
"<p>Principales améliorations :</p>"
"<ul>"
"<li>Meilleure différenciation des laits, des boissons lactées sucrées et des boissons végétales</li>"
"<li>Meilleur classement des boissons pour favoriser les boissons peu sucrées sans édulcorants</li>"
"<li>Notes plus basses pour les produits contenant trop de sel ou de sucre</li>"
"<li>Notes plus élevées pour certains poissons gras et huiles riches en bonnes graisses</li>"
"<li>Notes plus basses pour la viande rouge</li>"
"</ul>"

msgctxt "nutriscore_new_computation_link_text"
msgid "Discover all the improvements of the new Nutri-Score"
msgstr "Découvrez toutes les améliorations du nouveau Nutri-Score"

msgctxt "nutriscore_explanation_what_it_is"
msgid "The Nutri-Score is a logo on the overall nutritional quality of products."
msgstr "Le Nutri-Score est un logo sur la qualité nutritionnelle globale des produits."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,13 @@
}
},
[% END %]
// New Nutri-Score
{
"element_type": "panel",
"panel_element": {
"panel_id": "nutriscore_new_computation",
},
},
// Explanation of Nutri-Score
{
"element_type": "panel",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
"level": "info",
"topics": [
"health"
],
"title_element": {
"icon_url": "[% static_subdomain %]/images/icons/dist/info.svg",
"icon_size": "small",
"title": "[% edq(lang('nutriscore_new_computation_title')) %]",
"type": "info",
},
"elements": [
// Explanation of Nutri-Score
{
"element_type": "text",
"text_element": {
"type": "info",
"html": `[% lang("nutriscore_new_computation_description") %]
`,
}
},
{
"element_type": "text",
"text_element": {
// Display the link to the new Nutri-Score computation page
// on mobile: keep the /nutriscore-v2 link until the app can handle the new URLs
"html": `
<p>&rarr; <a href="[% IF knowledge_panels_options.knowledge_panels_client == 'web' %]/new-nutri-score[% ELSE %]/nutriscore-v2[% END %]">[% lang('nutriscore_new_computation_link_text') %]</a></p>
`
},
},
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
"image": [% encode_json(panel.nutrition_image) %],
[% END %]
"panel_ids": [
[% IF panels.nutriscore_2023.defined %]
"nutriscore_2023",
[% END %]
[% IF panels.nutriscore.defined %]
"nutriscore",
[% END %]
[% IF panels.nutriscore_2023.defined %]
"nutriscore_2023",
[% END %]
[% IF panels.nutrient_level_fat.defined || panels.${'nutrient_level_saturated-fat'}.defined || panels.nutrient_level_sugars.defined || panels.nutrient_level_salt.defined %]
"nutrient_levels",
[% END %]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1939,6 +1939,12 @@
"type" : "warning"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "nutriscore_new_computation"
}
},
{
"element_type" : "panel",
"panel_element" : {
Expand Down Expand Up @@ -2189,6 +2195,33 @@
"health"
]
},
"nutriscore_new_computation" : {
"elements" : [
{
"element_type" : "text",
"text_element" : {
"html" : "<p>The computation of the Nutri-Score is evolving to provide better recommendations based on the latest scientific evidence.</p><p>Main improvements:</p><ul><li>Better differentiation of milks, sweetened dairy drinks and plant-based drinks</li><li>Better ranking of drinks to favor low-sugar drinks without sweeteners</li><li>Lower grades for products that contain too much salt or sugar</li><li>Higher grades for some fatty fish and oils rich in good fats</li><li>Lower grades for red meat</li></ul>\n ",
"type" : "info"
}
},
{
"element_type" : "text",
"text_element" : {
"html" : "\n<p>&rarr; <a href=\"http://world.openfoodfacts.localhost/nutriscore-v2\">Discover all the improvements of the new Nutri-Score</a></p>\n"
}
}
],
"level" : "info",
"title_element" : {
"icon_size" : "small",
"icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/info.svg",
"title" : "Discover the new Nutri-Score!",
"type" : "info"
},
"topics" : [
"health"
]
},
"nutrition_facts_table" : {
"elements" : [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2593,6 +2593,12 @@
"type" : "warning"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "nutriscore_new_computation"
}
},
{
"element_type" : "panel",
"panel_element" : {
Expand Down Expand Up @@ -2843,6 +2849,33 @@
"health"
]
},
"nutriscore_new_computation" : {
"elements" : [
{
"element_type" : "text",
"text_element" : {
"html" : "<p>The computation of the Nutri-Score is evolving to provide better recommendations based on the latest scientific evidence.</p><p>Main improvements:</p><ul><li>Better differentiation of milks, sweetened dairy drinks and plant-based drinks</li><li>Better ranking of drinks to favor low-sugar drinks without sweeteners</li><li>Lower grades for products that contain too much salt or sugar</li><li>Higher grades for some fatty fish and oils rich in good fats</li><li>Lower grades for red meat</li></ul>\n ",
"type" : "info"
}
},
{
"element_type" : "text",
"text_element" : {
"html" : "\n<p>&rarr; <a href=\"http://world.openfoodfacts.localhost/nutriscore-v2\">Discover all the improvements of the new Nutri-Score</a></p>\n"
}
}
],
"level" : "info",
"title_element" : {
"icon_size" : "small",
"icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/info.svg",
"title" : "Discover the new Nutri-Score!",
"type" : "info"
},
"topics" : [
"health"
]
},
"nutrition_facts_table" : {
"elements" : [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,12 @@
"type" : "warning"
}
},
{
"element_type" : "panel",
"panel_element" : {
"panel_id" : "nutriscore_new_computation"
}
},
{
"element_type" : "panel",
"panel_element" : {
Expand Down Expand Up @@ -839,6 +845,33 @@
"health"
]
},
"nutriscore_new_computation" : {
"elements" : [
{
"element_type" : "text",
"text_element" : {
"html" : "<p>The computation of the Nutri-Score is evolving to provide better recommendations based on the latest scientific evidence.</p><p>Main improvements:</p><ul><li>Better differentiation of milks, sweetened dairy drinks and plant-based drinks</li><li>Better ranking of drinks to favor low-sugar drinks without sweeteners</li><li>Lower grades for products that contain too much salt or sugar</li><li>Higher grades for some fatty fish and oils rich in good fats</li><li>Lower grades for red meat</li></ul>\n ",
"type" : "info"
}
},
{
"element_type" : "text",
"text_element" : {
"html" : "\n<p>&rarr; <a href=\"http://world.openfoodfacts.localhost/nutriscore-v2\">Discover all the improvements of the new Nutri-Score</a></p>\n"
}
}
],
"level" : "info",
"title_element" : {
"icon_size" : "small",
"icon_url" : "http://static.openfoodfacts.localhost/images/icons/dist/info.svg",
"title" : "Discover the new Nutri-Score!",
"type" : "info"
},
"topics" : [
"health"
]
},
"nutrition_facts_table" : {
"elements" : [
{
Expand Down
Loading

0 comments on commit e1a7800

Please sign in to comment.