";
}
@@ -4222,9 +4222,9 @@ sub display_search_results($) {
display_barcode => $User{display_barcode},
edit_link => $User{edit_link},
}));
-
+
my $preferences_text = lang("classify_products_according_to_your_preferences");
-
+
$scripts .= <
var page_type = "products";
@@ -4295,9 +4295,9 @@ sub add_country_and_owner_filters_to_query($$) {
# Country filter
if (defined $country) {
-
+
# Do not add a country restriction if the query specifies a list of codes
-
+
if (($country ne 'en:world') and (not defined $query_ref->{code})) {
# we may already have a condition on countries (e.g. from the URL /country/germany )
if (not defined $query_ref->{countries_tags}) {
@@ -4425,12 +4425,12 @@ sub add_params_to_query($$) {
my $and = $query_ref->{"\$and"};
foreach my $field (param()) {
-
- $log->debug("add_params_to_query - field", { field => $field }) if $log->is_debug();
-
+
+ $log->debug("add_params_to_query - field", { field => $field }) if $log->is_debug();
+
# skip params that are not query filters
next if (defined $ignore_params{$field});
-
+
if (($field eq "page") or ($field eq "page_size")) {
$request_ref->{$field} = param($field) + 0; # Make sure we have a number
}
@@ -4586,16 +4586,16 @@ sub add_params_to_query($$) {
}
}
}
-
+
# Exact match on a specific field (e.g. "code")
elsif (defined $valid_params{$field}) {
-
+
my $values = remove_tags_and_quote(decode utf8=>param($field));
-
+
# Possible values:
# xyz=a
# xyz=a|b xyz=a,b xyz=a+b products with either xyz a or xyz b
-
+
if ($values =~ /\||\+|,/) {
# Multiple values: construct a MongoDB $in query
my @values = split(/\||\+|,/, $values);
@@ -4616,7 +4616,7 @@ sub add_params_to_query($$) {
$query_ref->{$field} = $values;
}
}
- }
+ }
}
}
@@ -4647,7 +4647,7 @@ Reference to the customized product object.
=cut
sub customize_response_for_product($$) {
-
+
my $request_ref = shift;
my $product_ref = shift;
@@ -4656,15 +4656,15 @@ sub customize_response_for_product($$) {
my $carbon_footprint_computed = 0;
my $fields = param('fields');
-
+
# For non API queries, we need to compute attributes for personal search
if (((not defined $fields) or ($fields eq "")) and ($user_preferences) and (not $request_ref->{api})) {
$fields = "code,product_display_name,url,image_front_thumb_url,attribute_groups";
}
-
+
# Localize the Eco-Score fields that depend on the country of the request
localize_ecoscore($cc, $product_ref);
-
+
foreach my $field (split(/,/, $fields)) {
# On demand carbon footprint tags -- deactivated: the environmental footprint infocard is now replaced by the Eco-Score details
@@ -4689,7 +4689,7 @@ sub customize_response_for_product($$) {
$customized_product_ref->{$field} = display_ecoscore_calculation_details_simple_html($cc, $product_ref->{ecoscore_data});
}
}
-
+
# fields in %language_fields can have different values by language
# by priority, return the first existing value in the language requested,
# possibly multiple languages if sent ?lc=fr,nl for instance,
@@ -4836,7 +4836,7 @@ sub search_and_display_products($$$$$) {
# If user preferences are turned on, return 100 products per page
elsif ((not defined $request_ref->{api}) and ($user_preferences)) {
$limit = 100;
- }
+ }
else {
$limit = $page_size;
}
@@ -4886,11 +4886,11 @@ sub search_and_display_products($$$$$) {
$sort_by = 'last_modified_t';
}
}
-
+
if ((defined $sort_by) and ($sort_by ne "nothing")) {
my $order = 1;
my $sort_by_key = $sort_by;
-
+
if ($sort_by eq 'last_modified_t_complete_first') {
# replace last_modified_t_complete_first (used on front page of a country) by popularity
$sort_by = 'popularity';
@@ -4903,7 +4903,7 @@ sub search_and_display_products($$$$$) {
}
elsif ($sort_by eq "popularity_key") {
$order = -1;
- }
+ }
elsif ($sort_by eq "ecoscore_score") {
$order = -1;
}
@@ -4927,27 +4927,27 @@ sub search_and_display_products($$$$$) {
$sort_ref->Push($sort_by_key => $order);
}
-
+
# Sort options
-
+
$template_data_ref->{sort_options} = [];
# Nutri-Score and Eco-Score are only for food products
# and currently scan data is only loaded for Open Food Facts
if ((defined $options{product_type}) and ($options{product_type} eq "food")) {
-
+
push @{$template_data_ref->{sort_options}}, { value => "popularity", link => $request_ref->{current_link} . "?sort_by=popularity", name => lang("sort_by_popularity") };
push @{$template_data_ref->{sort_options}}, { value => "nutriscore_score", link => $request_ref->{current_link} . "?sort_by=nutriscore_score", name => lang("sort_by_nutriscore_score") };
-
+
# Show Eco-score sort only for some countries, or for moderators
if ($show_ecoscore) {
push @{$template_data_ref->{sort_options}}, { value => "ecoscore_score", link => $request_ref->{current_link} . "?sort_by=ecoscore_score", name => lang("sort_by_ecoscore_score") };
}
}
-
+
push @{$template_data_ref->{sort_options}}, { value => "created_t", link => $request_ref->{current_link} . "?sort_by=created_t", name => lang("sort_by_created_t") };
push @{$template_data_ref->{sort_options}}, { value => "last_modified_t", link => $request_ref->{current_link} . "?sort_by=last_modified_t", name => lang("sort_by_last_modified_t") };
-
+
my $count;
my $page_count;
@@ -4972,7 +4972,7 @@ sub search_and_display_products($$$$$) {
"generic_name" => 1,
"generic_name_$lc" => 1,
"abbreviated_product_name" => 1,
- "abbreviated_product_name_$lc" => 1,
+ "abbreviated_product_name_$lc" => 1,
"brands" => 1,
"images" => 1,
"quantity" => 1
@@ -5040,17 +5040,17 @@ sub search_and_display_products($$$$$) {
$key_count = "search-count-" . md5_hex($key_count);
my $results_count = get_cache_results($key_count,$request_ref);
if (not defined $results_count) {
-
+
$log->debug("count not in cache for query", { key => $key_count }) if $log->is_debug();
-
+
# Count queries are very expensive, if possible, execute them on the smaller products_tags collection
my $only_tags_filters = 1;
-
+
if ($server_options{producers_platform}) {
$only_tags_filters = 0;
}
else {
-
+
foreach my $field (keys %$query_ref) {
if ($field !~ /_tags$/) {
$log->debug("non tags field in query filters, cannot use smaller products_tags collection", { field => $field, value => $query_ref->{field} }) if $log->is_debug();
@@ -5059,9 +5059,9 @@ sub search_and_display_products($$$$$) {
}
}
}
-
+
if (($only_tags_filters) and ((not defined param("no_cache")) or (param("no_cache") == 0))) {
-
+
$count = execute_query(sub {
$log->debug("count_documents on smaller products_tags collection", { key => $key_count }) if $log->is_debug();
return get_products_tags_collection()->count_documents($query_ref);
@@ -5069,7 +5069,7 @@ sub search_and_display_products($$$$$) {
}
else {
-
+
$count = execute_query(sub {
$log->debug("count_documents on complete products collection", { key => $key_count }) if $log->is_debug();
return get_products_collection()->count_documents($query_ref);
@@ -5114,18 +5114,18 @@ sub search_and_display_products($$$$$) {
push @{$request_ref->{structured_response}{products}}, $product_ref;
$page_count++;
}
-
+
$request_ref->{structured_response}{page_count} = $page_count;
-
+
# The page count may be higher than the count from the products_tags collection which is updated every night
# in that case, set $count to $page_count
# It's also possible that the count query had a timeout and that $count is 0 even though we have results
if ($page_count > $count) {
$count = $page_count;
}
-
+
$request_ref->{structured_response}{count} = $count;
-
+
# Don't set the cache if no_count was set
if (not param('no_count')) {
set_cache_results($key,$request_ref->{structured_response})
@@ -5168,7 +5168,7 @@ sub search_and_display_products($$$$$) {
$template_data_ref->{world_subdomain} = $world_subdomain;
$template_data_ref->{current_link_query} = $request_ref->{current_link_query};
$template_data_ref->{sort_by} = $sort_by;
-
+
# Query from search form: display a link back to the search form
if ($request_ref->{current_link_query} =~ /action=process/) {
$template_data_ref->{current_link_query_edit} = $request_ref->{current_link_query};
@@ -5217,9 +5217,9 @@ sub search_and_display_products($$$$$) {
}
foreach my $newtagtype (@current_drilldown_fields) {
-
+
# Eco-score: currently only for moderators
-
+
if ($newtagtype eq 'ecoscore') {
next if not ($show_ecoscore);
}
@@ -5289,14 +5289,14 @@ sub search_and_display_products($$$$$) {
}
# Disable nested ingredients in ingredients field (bug #2883)
-
+
# 2021-02-25: we now store only nested ingredients, flatten them if the API is <= 1
-
+
if ((defined param("api_version")) and (param("api_version") <= 1)) {
for my $product_ref (@{$request_ref->{structured_response}{products}}) {
if (defined $product_ref->{ingredients}) {
-
+
flatten_sub_ingredients($product_ref);
foreach my $ingredient_ref (@{$product_ref->{ingredients}}) {
@@ -5323,9 +5323,9 @@ sub search_and_display_products($$$$$) {
}
if ($user_preferences) {
-
+
my $preferences_text = sprintf(lang("classify_the_d_products_below_according_to_your_preferences"), $page_count);
-
+
my $products_json = '[]';
if (defined $request_ref->{structured_response}{products}) {
@@ -5336,7 +5336,7 @@ sub search_and_display_products($$$$$) {
display_barcode => $User{display_barcode},
edit_link => $User{edit_link},
}));
-
+
$scripts .= <
@@ -7093,7 +7093,7 @@ JS
$template_data_ref->{h1_title} = $h1_title;
$template_data_ref->{content_ref} = $$content_ref;
$template_data_ref->{join_us_on_slack} = $join_us_on_slack;
-
+
# init javascript code
$template_data_ref->{scripts} = $scripts;
@@ -7207,8 +7207,10 @@ HTML
$idlc = $2;
}
+ my $unselect_image = lang('unselect_image');
+
my $html = <
+
HTML
;
@@ -7485,7 +7487,7 @@ CSS
$template_data_ref->{ecoscore_score} = $product_ref->{ecoscore_data}{"score"};
$template_data_ref->{ecoscore_data} = $product_ref->{ecoscore_data};
$template_data_ref->{ecoscore_calculation_details} = display_ecoscore_calculation_details($cc, $product_ref->{ecoscore_data});
- }
+ }
# Knowledge panels are in development, they can be activated with the "panels" parameter
# for debugging and demonstration purposes
@@ -7494,7 +7496,7 @@ CSS
create_knowledge_panels($product_ref, $lc, $cc, $knowledge_panels_options_ref);
$template_data_ref->{environment_card_panel} = display_knowledge_panel($product_ref->{"knowledge_panels_" . $lc}, "environment_card");
$template_data_ref->{health_card_panel} = display_knowledge_panel($product_ref->{"knowledge_panels_" . $lc}, "health_card");
- }
+ }
# On the producers platform, show a link to the public platform
@@ -8822,7 +8824,7 @@ sub data_to_display_nutriscore_and_nutrient_levels($) {
$result_data_ref->{nutriscore_grade} = "not-applicable";
$result_data_ref->{nutriscore_unknown_reason} = "not_applicable";
$result_data_ref->{nutriscore_unknown_reason_short} = lang("nutriscore_not_applicable_short");
- }
+ }
else {
$result_data_ref->{nutriscore_grade} = "unknown";
@@ -8850,7 +8852,7 @@ sub data_to_display_nutriscore_and_nutrient_levels($) {
if (defined $product_ref->{nutriscore_data}) {
$result_data_ref->{nutriscore_details} = display_nutriscore_calculation_details($product_ref->{nutriscore_data});
}
-
+
# Nutrient levels data
@@ -8896,7 +8898,7 @@ sub data_to_display_nutriscore_and_nutrient_levels($) {
}
}
}
-
+
return $result_data_ref;
}
@@ -9162,7 +9164,7 @@ sub data_to_display_nutrition_table($$) {
per => "serving",
name => $col_name . " " . lang("nutrition_data_per_serving"),
short_name => lang("nutrition_data_per_serving"),
- };
+ };
if ((defined $product_ref->{serving_size}) and ($product_ref->{serving_size} ne '')) {
$columns{$product_type . "serving"}{name} .= ' (' . $product_ref->{serving_size} . ')';
@@ -9367,10 +9369,10 @@ CSS
}
if ($shown) {
-
+
# Level of the nutrient: 0 for main nutrients, 1 for sub-nutrients, 2 for sub-sub-nutrients
my $level = 0;
-
+
if ($nutriment =~ /^!?-/) {
$level = 1;
if ($nutriment =~ /^!?--/) {
@@ -9526,7 +9528,7 @@ CSS
my $prepared = '';
if ($col_id =~ /prepared/) {
$prepared = "_prepared";
- }
+ }
if ((not defined $product_ref->{nutriments}{$nid . "_" . $col_id}) or ($product_ref->{nutriments}{$nid . "_" . $col_id} eq '')) {
if ((defined $product_ref->{nutriments}{$nid . $prepared . "_modifier"})
@@ -9670,11 +9672,11 @@ CSS
if (defined $percent_numeric_value) {
my $nutrient_evaluation = get_property("nutrients", "zz:$nid", "evaluation:en"); # Whether the nutrient is considered good or not
-
+
# Determine if the value of this nutrient compared to other products is good or not
if (defined $nutrient_evaluation) {
-
+
if ((($nutrient_evaluation eq "good") and ($percent_numeric_value >= 10))
or (($nutrient_evaluation eq "bad") and ($percent_numeric_value <= -10))) {
$cell_data_ref->{evaluation} = "good";
@@ -9813,12 +9815,12 @@ sub display_preferences_api($$)
$request_ref->{structured_response} = [];
foreach my $preference ("not_important", "important", "very_important", "mandatory") {
-
+
my $preference_ref = {
id => $preference,
name => lang("preference_" . $preference),
};
-
+
if ($preference eq "important") {
$preference_ref->{factor} = 1;
}
@@ -9828,8 +9830,8 @@ sub display_preferences_api($$)
elsif ($preference eq "mandatory") {
$preference_ref->{factor} = 4;
$preference_ref->{minimum_match} = 20;
- }
-
+ }
+
push @{$request_ref->{structured_response}}, $preference_ref;
}
@@ -9927,7 +9929,7 @@ sub display_taxonomy_api($) {
$request_ref->{structured_response} = $taxonomy_ref;
display_structured_response($request_ref);
-
+
return;
}
@@ -9938,13 +9940,13 @@ sub display_product_api($) {
# Is a sample product requested?
if ((defined $request_ref->{code}) and ($request_ref->{code} eq "example")) {
-
+
$request_ref->{code} = $options{"sample_product_code_country_${cc}_language_${lc}"}
|| $options{"sample_product_code_country_${cc}"}
|| $options{"sample_product_code_language_${lc}"}
|| $options{"sample_product_code"}
|| "";
- }
+ }
my $code = normalize_code($request_ref->{code});
my $product_id = product_id_for_owner($Owner_id, $code);
@@ -10044,7 +10046,7 @@ HTML
if (defined param('fields')) {
$log->debug("display_product_api - fields parameter is set", { fields => param('fields') }) if $log->is_debug();
-
+
my $customized_product_ref = customize_response_for_product($request_ref, $product_ref);
# 2019-05-10: the OFF Android app expects the _serving fields to always be present, even with a "" value
@@ -10070,13 +10072,13 @@ HTML
}
# Disable nested ingredients in ingredients field (bug #2883)
-
+
# 2021-02-25: we now store only nested ingredients, flatten them if the API is <= 1
-
+
if ((defined param("api_version")) and (param("api_version") <= 1)) {
if (defined $product_ref->{ingredients}) {
-
+
flatten_sub_ingredients($product_ref);
foreach my $ingredient_ref (@{$product_ref->{ingredients}}) {
@@ -10084,7 +10086,7 @@ HTML
exists $ingredient_ref->{ingredients} and delete $ingredient_ref->{ingredients};
}
}
- }
+ }
# Return blame information
if (defined param("blame")) {
@@ -10972,7 +10974,7 @@ sub display_ecoscore_calculation_details_simple_html($$) {
# Generate a data structure that we will pass to the template engine
- my $template_data_ref = dclone($ecoscore_data_ref);
+ my $template_data_ref = dclone($ecoscore_data_ref);
# Eco-score Calculation Template
@@ -10993,7 +10995,7 @@ sub search_and_analyze_recipes($$) {
my $request_ref = shift;
my $query_ref = shift;
-
+
add_params_to_query($request_ref, $query_ref);
add_country_and_owner_filters_to_query($request_ref, $query_ref);
@@ -11023,7 +11025,7 @@ sub search_and_analyze_recipes($$) {
if ((defined $server_options{private_products}) and ($server_options{private_products})) {
$fields_ref->{owner} = 1;
}
-
+
eval {
$cursor = execute_query(sub {
return get_products_collection()->query($query_ref)->fields($fields_ref);
diff --git a/po/common/common.pot b/po/common/common.pot
index f4c8c34f5ad6d..a112abc601779 100644
--- a/po/common/common.pot
+++ b/po/common/common.pot
@@ -5482,7 +5482,7 @@ msgstr "The Eco-Score can only be calculated if the product has a sufficiently p
msgctxt "ecoscore_add_more_precise_category"
msgid "You can modify the product page to add a more precise category."
msgstr "You can modify the product page to add a more precise category."
-
+
msgctxt "ecoscore_platform_promo"
msgid "If you are the manufacturer of this product, you can send us the information with our free platform for producers."
msgstr "If you are the manufacturer of this product, you can send us the information with our free platform for producers."
@@ -5490,7 +5490,7 @@ msgstr "If you are the manufacturer of this product, you can send us the informa
msgctxt "ecoscore_warning_missing_information"
msgid "Warning: some information necessary to calculate the Eco-Score with precision is not provided (see the details of the calculation below)."
msgstr "Warning: some information necessary to calculate the Eco-Score with precision is not provided (see the details of the calculation below)."
-
+
msgctxt "ecoscore_add_missing_information"
msgid "You can edit the product to add the missing information."
msgstr "You can edit the product to add the missing information."
@@ -5765,21 +5765,21 @@ msgstr "%s g / 100 g"
msgctxt "donation_title"
msgid "Important: we need your support!"
-msgstr ""
+msgstr ""
# variable names between { } must not be translated, {number_of_employees} will be a number
msgctxt "donation_body_employees"
msgid "Open Food Facts is a collaborative project built by tens of thousands of volunteers and managed by a non-profit organization with {number_of_employees} employees."
-msgstr ""
+msgstr ""
# variable names between { } must not be translated, {year} will be the upcoming year
msgctxt "donation_why_year"
msgid "We need your donations to fund the Open Food Facts {year} budget and to continue to develop the project."
-msgstr ""
+msgstr ""
msgctxt "donation_cta"
msgid "Donate"
-msgstr ""
+msgstr ""
msgctxt "ecoscore_production_system_no_labels_with_environmental_benefits"
msgid "No labels with environmental benefits"
@@ -6069,4 +6069,8 @@ msgstr "The ingredients of the product must be specified in order to determine t
msgctxt "nova_group_too_many_unknown_ingredient"
msgid "We could not recognize some of the ingredients and determine the NOVA group."
-msgstr "We could not recognize some of the ingredients and determine the NOVA group."
\ No newline at end of file
+msgstr "We could not recognize some of the ingredients and determine the NOVA group."
+
+msgctxt "unselect_image"
+msgid "Unselect Image"
+msgstr ""
diff --git a/po/common/en.po b/po/common/en.po
index 8bee9dc4c1bb0..68fb5a9b5315f 100644
--- a/po/common/en.po
+++ b/po/common/en.po
@@ -5503,7 +5503,7 @@ msgstr "The Eco-Score can only be calculated if the product has a sufficiently p
msgctxt "ecoscore_add_more_precise_category"
msgid "You can modify the product page to add a more precise category."
msgstr "You can modify the product page to add a more precise category."
-
+
msgctxt "ecoscore_platform_promo"
msgid "If you are the manufacturer of this product, you can send us the information with our free platform for producers."
msgstr "If you are the manufacturer of this product, you can send us the information with our free platform for producers."
@@ -5511,7 +5511,7 @@ msgstr "If you are the manufacturer of this product, you can send us the informa
msgctxt "ecoscore_warning_missing_information"
msgid "Warning: some information necessary to calculate the Eco-Score with precision is not provided (see the details of the calculation below)."
msgstr "Warning: some information necessary to calculate the Eco-Score with precision is not provided (see the details of the calculation below)."
-
+
msgctxt "ecoscore_add_missing_information"
msgid "You can edit the product to add the missing information."
msgstr "You can edit the product to add the missing information."
@@ -5821,17 +5821,17 @@ msgstr "Ingredients for each product"
msgctxt "donation_title"
msgid "Important: we need your support!"
-msgstr "Important: we need your support!"
+msgstr "Important: we need your support!"
# variable names between { } must not be translated, {number_of_employees} will be a number
msgctxt "donation_body_employees"
msgid "Open Food Facts is a collaborative project built by tens of thousands of volunteers and managed by a non-profit organization with {number_of_employees} employees."
-msgstr "Open Food Facts is a collaborative project built by tens of thousands of volunteers and managed by a non-profit organization with {number_of_employees} employees."
+msgstr "Open Food Facts is a collaborative project built by tens of thousands of volunteers and managed by a non-profit organization with {number_of_employees} employees."
# variable names between { } must not be translated, {year} will be the upcoming year
msgctxt "donation_why_year"
msgid "We need your donations to fund the Open Food Facts {year} budget and to continue to develop the project."
-msgstr "We need your donations to fund the Open Food Facts {year} budget and to continue to develop the project."
+msgstr "We need your donations to fund the Open Food Facts {year} budget and to continue to develop the project."
msgctxt "donation_cta"
msgid "Donate"
@@ -6090,3 +6090,7 @@ msgstr "The ingredients of the product must be specified in order to determine t
msgctxt "nova_group_too_many_unknown_ingredient"
msgid "We could not recognize some of the ingredients and determine the NOVA group."
msgstr "We could not recognize some of the ingredients and determine the NOVA group."
+
+msgctxt "unselect_image"
+msgid "Unselect Image"
+msgstr "Unselect Image"
From 255dfa1077d8289e07cfcbcef8c0b4c004a1a3ca Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?St=C3=A9phane=20Gigandet?=
Date: Thu, 7 Apr 2022 15:26:21 +0200
Subject: [PATCH 2/2] add Hindi for testing
---
lib/ProductOpener/Display.pm | 2 +-
po/common/hi.po | 4 ++++
2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/lib/ProductOpener/Display.pm b/lib/ProductOpener/Display.pm
index 242e1f0440f30..dd89a89c0f8f3 100644
--- a/lib/ProductOpener/Display.pm
+++ b/lib/ProductOpener/Display.pm
@@ -7210,7 +7210,7 @@ HTML
my $unselect_image = lang('unselect_image');
my $html = <
+
HTML
;
diff --git a/po/common/hi.po b/po/common/hi.po
index 0e54ea54981d2..6b2d6c7b02045 100644
--- a/po/common/hi.po
+++ b/po/common/hi.po
@@ -5861,3 +5861,7 @@ msgctxt "unrecognized_ingredients"
msgid "Unrecognized ingredients"
msgstr ""
+msgctxt "unselect_image"
+msgid "Unselect Image"
+msgstr "छवि को अचयनित करें"
+