Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add link to learn more about nutriscore + ecoscore #6701

Merged
merged 1 commit into from
Apr 27, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6078,3 +6078,11 @@ msgstr "We could not recognize some of the ingredients and determine the NOVA gr
msgctxt "unselect_image"
msgid "Unselect Image"
msgstr ""

msgctxt "nutriscore_learn_more"
msgid "Learn more about the Nutri-Score"
msgstr "Learn more about the Nutri-Score"

msgctxt "ecoscore_learn_more"
msgid "Learn more about the Eco-Score"
msgstr "Learn more about the Eco-Score"
8 changes: 8 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -6101,3 +6101,11 @@ msgstr "We could not recognize some of the ingredients and determine the NOVA gr
msgctxt "unselect_image"
msgid "Unselect Image"
msgstr "Unselect Image"

msgctxt "nutriscore_learn_more"
msgid "Learn more about the Nutri-Score"
msgstr "Learn more about the Nutri-Score"

msgctxt "ecoscore_learn_more"
msgid "Learn more about the Eco-Score"
msgstr "Learn more about the Eco-Score"
Original file line number Diff line number Diff line change
Expand Up @@ -58,5 +58,13 @@
"panel_ids": [ "ecoscore_total"],
},
},
{
"element_type": "text",
"text_element": {
"html": `
<p>&rarr; <a href="[% url_for_text("ecoscore") %]">[% lang('ecoscore_learn_more') %]</a></p>
`
},
},
]
}
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,13 @@
"html": `[% panel.nutriscore_details %]`,
}
},
{
"element_type": "text",
"text_element": {
"html": `
<p>&rarr; <a href="/nutriscore">[% lang('nutriscore_learn_more') %]</a></p>
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not url_for_text("nutriscore") here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

url_for_text() currently only works for the Eco-Score text, the /nutriscore text URL is not localized, it's the same for all languages.

=head2 url_for_text ( $textid )

Return the localized URL for a text. (e.g. "data" points to /data in English and /donnees in French)

=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 = (
	"ecoscore" => {
		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($) {

	my $textid = shift;

	# 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;
	}
}

`
},
},
]
}