Skip to content

Commit

Permalink
fix: ingredients and nutrition should have titles (#6839)
Browse files Browse the repository at this point in the history
* fix: ingredients and nutrition should have titles

because we made them collapsible.

fixes: #6835
  • Loading branch information
alexgarel committed Jun 2, 2022
1 parent 84d9b9b commit 8048013
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 6 deletions.
1 change: 1 addition & 0 deletions icons/ingredients.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 1 addition & 0 deletions icons/nutrition.svg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions lib/ProductOpener/KnowledgePanels.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1031,7 +1031,17 @@ sub create_ingredients_panel($$$) {
$ingredients_text_lc = $target_lc;
}

my $title ="";
if (!(defined $product_ref->{ingredients_n}) or ($product_ref->{ingredients_n} == 0)) {
$title = lang("no_ingredient");
} elsif ($product_ref->{ingredients_n} == 1) {
$title = lang("one_ingredient");
} else {
$title = f_lang("f_ingredients_with_number", { number => $product_ref->{ingredients_n} });
}

my $panel_data_ref = {
title => $title,
ingredients_text => $ingredients_text,
ingredients_text_with_allergens => $ingredients_text_with_allergens,
ingredients_text_lc => $ingredients_text_lc,
Expand Down
12 changes: 12 additions & 0 deletions po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -1056,6 +1056,18 @@ msgctxt "ingredients"
msgid "Ingredients"
msgstr ""

msgctxt "no_ingredient"
msgid "Ingredients are missing"
msgstr "Ingredients are missing"

msgctxt "one_ingredient"
msgid "1 ingredient"
msgstr "1 ingredient"

msgctxt "f_ingredients_with_number"
msgid "{number} ingredients"
msgstr "{number} ingredients"

msgctxt "ingredients_alt"
msgid "Ingredients"
msgstr ""
Expand Down
12 changes: 12 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -1018,6 +1018,18 @@ msgctxt "ingredients"
msgid "Ingredients"
msgstr "Ingredients"

msgctxt "no_ingredient"
msgid "Ingredients are missing"
msgstr "Ingredients are missing"

msgctxt "one_ingredient"
msgid "1 ingredient"
msgstr "1 ingredient"

msgctxt "f_ingredients_with_number"
msgid "{number} ingredients"
msgstr "{number} ingredients"

msgctxt "ingredients_alt"
msgid "Ingredients"
msgstr "Ingredients"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,19 @@
"topics": [
"health"
],
"type": "inline",
"expanded": false,
"expand_for": "large",
"title_element": {
"title":"[% panel.title %]",
"icon_url": "[% static_subdomain %]/images/icons/dist/ingredients.svg",
},
"elements": [
{
"element_type": "text",
"text_element": {
"html": `[% panel.ingredients_text_with_allergens %]`,
"lc": "[% panel.ingredients_text_lc %]",
"language": "[% panel.ingredients_text_language %]",
"language": "[% panel.ingredients_text_language %]",
"edit_field_type": "ingredients_text",
"edit_field_id": "ingredients_text_[% panel.ingredients_text_lc %]",
"edit_field_value": `[% panel.ingredients_text %]`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,17 @@
"topics": [
"health"
],
"type": "inline",
"expanded": false,
"expand_for": "large",
"elements": [
"title_element": {
"title": "[% lang('nutrition_data_table') %]",
"icon_url": "[% static_subdomain %]/images/icons/dist/nutrition.svg",
},
"elements": [
{
"element_type": "table",
"table_element": {
"id": "nutrition_facts_table",
"title": "[% lang('nutrition_data_table') %]",
// Create a structure to check if we already have seen a column for a given scope
// so that we can mark the first one as the default column for the group
[% SET scopes = {} %]
Expand Down Expand Up @@ -67,7 +69,7 @@
[% END %]
]
}
},
},

]
}

0 comments on commit 8048013

Please sign in to comment.