From e9c8b84177cfde4bb67e8c7d9389c938917ac6e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Fri, 20 Dec 2024 12:19:24 +0100 Subject: [PATCH 1/8] fix: greenscore strings --- po/common/fr.po | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/po/common/fr.po b/po/common/fr.po index d7893bae3d7e2..1ce1e69386a87 100644 --- a/po/common/fr.po +++ b/po/common/fr.po @@ -5048,7 +5048,7 @@ msgstr "Note Green-Score" # do not translate Green-Score msgctxt "environmental_score_calculation_details" msgid "Details of the calculation of the Green-Score" -msgstr "Détails du calcul de le Green-Score" +msgstr "Détails du calcul du Green-Score" # do not translate Green-Score msgctxt "environmental_score_information" @@ -5705,7 +5705,7 @@ msgstr "Les informations sur les ingrédients de ce produit ne sont pas indiqué msgctxt "environmental_score_edit_for_more_precise_environmental_score" msgid "For a more precise calculation of the Green-Score, you can edit the product page and add them." -msgstr "Pour un calcul plus précis de le Green-Score, vous pouvez modifier la fiche produit et les ajouter." +msgstr "Pour un calcul plus précis du Green-Score, vous pouvez modifier la fiche produit et les ajouter." msgctxt "environmental_score_packaging_ratio" msgid "ratio" @@ -5729,7 +5729,7 @@ msgstr "Les informations sur l'emballage de ce produit ne sont pas suffisamment msgctxt "environmental_score_edit_for_more_precise_environmental_score" msgid "For a more precise calculation of the Green-Score, you can modify the product page and add them." -msgstr "Pour un calcul plus précis de le Green-Score, vous pouvez modifier la fiche produit et les ajouter." +msgstr "Pour un calcul plus précis du Green-Score, vous pouvez modifier la fiche produit et les ajouter." msgctxt "environmental_score_final_score" msgid "Final score" @@ -5756,12 +5756,12 @@ msgstr "L'Green-Score est un score expérimental qu # do not translate Green-Score msgctxt "environmental_score_warning_fr" msgid "The Green-Score formula is subject to change as it is regularly improved to make it more precise." -msgstr "La formule de le Green-Score est susceptible d'évoluer car elle est régulièrement améliorée pour la rendre plus précise." +msgstr "La formule du Green-Score est susceptible d'évoluer car elle est régulièrement améliorée pour la rendre plus précise." # do not translate Green-Score msgctxt "environmental_score_warning_international" msgid "The Green-Score was initially developped for France and it is being extended to other European countries. The Green-Score formula is subject to change as it is regularly improved to make it more precise and better suited to each country." -msgstr "Le Green-Score a été initialement conçu pour la France et est en cours d'extension à d'autres pays européens. La formule de le Green-Score est susceptible d'évoluer car elle est régulièrement améliorée pour la rendre plus précise et mieux adaptée à chaque pays." +msgstr "Le Green-Score a été initialement conçu pour la France et est en cours d'extension à d'autres pays européens. La formule du Green-Score est susceptible d'évoluer car elle est régulièrement améliorée pour la rendre plus précise et mieux adaptée à chaque pays." msgctxt "environmental_score_warning_transportation_world" msgid "Select a country in order to include the full impact of transportation." From eae3b9d1493c70cf2afb2e88ad45a3b2b2f46b57 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Fri, 20 Dec 2024 13:57:20 +0100 Subject: [PATCH 2/8] green score --- po/common/fr.po | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/po/common/fr.po b/po/common/fr.po index 1ce1e69386a87..87c7d422d5f5e 100644 --- a/po/common/fr.po +++ b/po/common/fr.po @@ -5751,7 +5751,7 @@ msgstr "Si vous êtes le fabricant de ce produit, vous pouvez nous transmettre l # do not translate Green-Score and the link msgctxt "environmental_score_description" msgid "The Green-Score is an experimental score that summarizes the environmental impacts of food products." -msgstr "L'Green-Score est un score expérimental qui synthétise les impacts environnementaux des produits alimentaires." +msgstr "Le Green-Score est un score expérimental qui synthétise les impacts environnementaux des produits alimentaires." # do not translate Green-Score msgctxt "environmental_score_warning_fr" From e555e0395f13da1ddc0648113f3f8fdf3f26a24d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Gigandet?= Date: Fri, 20 Dec 2024 14:03:05 +0100 Subject: [PATCH 3/8] remove url_for_text --- lib/ProductOpener/Display.pm | 46 ------------------- .../environmental_score.tt.json | 2 +- tests/unit/display.t | 14 ------ 3 files changed, 1 insertion(+), 61 deletions(-) diff --git a/lib/ProductOpener/Display.pm b/lib/ProductOpener/Display.pm index da1589497e8c8..c32e6d8b4c6ae 100644 --- a/lib/ProductOpener/Display.pm +++ b/lib/ProductOpener/Display.pm @@ -104,7 +104,6 @@ BEGIN { &add_params_to_query &add_params_and_filters_to_query - &url_for_text &process_template @search_series @@ -329,47 +328,6 @@ $images_subdomain = format_subdomain('images'); =head1 FUNCTIONS - -=head2 url_for_text ( $textid ) - -Return the localized URL for a text. (e.g. "data" points to /data in English and /donnees in French) -Note: This currently only has environmental_score - -=cut - -# Note: the following urls are currently hardcoded, but the idea is to build the mapping table -# at startup from the available translated texts in the repository. (TODO) -my %urls_for_texts = ( - "environmental_score" => { - en => "eco-score-the-environmental-impact-of-food-products", - de => "eco-score-die-umweltauswirkungen-von-lebensmitteln", - es => "eco-score-el-impacto-medioambiental-de-los-productos-alimenticios", - fr => "eco-score-l-impact-environnemental-des-produits-alimentaires", - it => "eco-score-impatto-ambientale-dei-prodotti-alimentari", - nl => "eco-score-de-milieu-impact-van-voedingsproducten", - pt => "eco-score-o-impacto-ambiental-dos-produtos-alimentares", - }, -); - -sub url_for_text ($textid) { - - # remove starting / if passed - $textid =~ s/^\///; - - if (not defined $urls_for_texts{$textid}) { - return "/" . $textid; - } - elsif (defined $urls_for_texts{$textid}{$lc}) { - return "/" . $urls_for_texts{$textid}{$lc}; - } - elsif ($urls_for_texts{$textid}{en}) { - return "/" . $urls_for_texts{$textid}{en}; - } - else { - return "/" . $textid; - } -} - =head2 process_template ( $template_filename , $template_data_ref , $result_content_ref, $request_ref = {} ) Add some functions and variables needed by many templates and process the template with template toolkit. @@ -424,7 +382,6 @@ sub process_template ($template_filename, $template_data_ref, $result_content_re $template_data_ref->{display_date_without_time} = \&display_date_without_time; $template_data_ref->{display_date_ymd} = \&display_date_ymd; $template_data_ref->{display_date_tag} = \&display_date_tag; - $template_data_ref->{url_for_text} = \&url_for_text; $template_data_ref->{product_url} = \&product_url; $template_data_ref->{product_action_url} = \&product_action_url; $template_data_ref->{product_name_brand_quantity} = \&product_name_brand_quantity; @@ -7661,9 +7618,6 @@ sub display_page ($request_ref) { # Twitter account $html =~ s//$twitter_account/g; - # Replace urls for texts in links like with a localized name - $html =~ s/(href=")(\/[^"]+)/$1 . url_for_text($2)/eg; - my $status_code = $request_ref->{status_code} // 200; my $http_headers_ref = { diff --git a/templates/api/knowledge-panels/environment/environmental_score/environmental_score.tt.json b/templates/api/knowledge-panels/environment/environmental_score/environmental_score.tt.json index 65b7e1ac39c9d..1261d32eb397c 100644 --- a/templates/api/knowledge-panels/environment/environmental_score/environmental_score.tt.json +++ b/templates/api/knowledge-panels/environment/environmental_score/environmental_score.tt.json @@ -72,7 +72,7 @@ "element_type": "text", "text_element": { "html": ` -

[% lang('environmental_score_learn_more') %]

+

[% lang('environmental_score_learn_more') %]

` }, }, diff --git a/tests/unit/display.t b/tests/unit/display.t index 89107757647d6..8266b4397ec52 100644 --- a/tests/unit/display.t +++ b/tests/unit/display.t @@ -31,20 +31,6 @@ is(display_date_tag($t), '