Skip to content

Commit

Permalink
feat: Hunger Games on Facets (#7742)
Browse files Browse the repository at this point in the history
* feat: Hunger Games on Facets

* feat: make the string translatable

* feat: placeholder for string

* Update po/common/common.pot

* Update en.po

* expose canon_tagid in template

* Update lib/ProductOpener/Display.pm

Co-authored-by: Stéphane Gigandet <stephane@openfoodfacts.org>
  • Loading branch information
teolemon and stephanegigandet authored Nov 22, 2022
1 parent 8563789 commit 4a3b9d5
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
5 changes: 5 additions & 0 deletions lib/ProductOpener/Display.pm
Original file line number Diff line number Diff line change
Expand Up @@ -2978,6 +2978,8 @@ sub display_tag ($request_ref) {
$request_ref->{world_current_link} = add_tag_prefix_to_link($request_ref->{world_current_link}, $prefix);
$log->debug("Found tag prefix " . Dumper($request_ref)) if $log->is_debug();
}

$request_ref->{canon_tagid} = $canon_tagid;
}
else {
$log->warn("no tagid found") if $log->is_warn();
Expand Down Expand Up @@ -3045,6 +3047,8 @@ sub display_tag ($request_ref) {
$request_ref->{world_current_link} = add_tag_prefix_to_link($request_ref->{world_current_link}, $prefix);
$log->debug("Found tag prefix 2 " . Dumper($request_ref)) if $log->is_debug();
}

$request_ref->{canon_tagid2} = $canon_tagid2;
}

if (defined $request_ref->{groupby_tagtype}) {
Expand Down Expand Up @@ -7032,6 +7036,7 @@ JS

$template_data_ref->{scripts} = $scripts;
$template_data_ref->{initjs} = $initjs;
$template_data_ref->{request} = $request_ref;

my $html;
process_template('web/common/site_layout.tt.html', $template_data_ref, \$html)
Expand Down
6 changes: 6 additions & 0 deletions po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -6414,3 +6414,9 @@ msgstr "Failure"
msgctxt "api_impact_field_ignored"
msgid "Field ignored"
msgstr "Field ignored"

# variable names between { } must not be translated
msgctxt "f_help_categorize_on_hunger_games"
msgid "Help categorize more {title} on Hunger Games"
msgstr "Help categorize more {title} on Hunger Games"

5 changes: 5 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -6414,3 +6414,8 @@ msgstr "Failure"
msgctxt "api_impact_field_ignored"
msgid "Field ignored"
msgstr "Field ignored"

# variable names between { } must not be translated
msgctxt "f_help_categorize_on_hunger_games"
msgid "Help categorize more {title} on Hunger Games"
msgstr "Help categorize more {title} on Hunger Games"
13 changes: 11 additions & 2 deletions templates/web/common/site_layout.tt.html
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,17 @@
<div itemscope itemtype="[% schema_org_itemtype %]">
<div class="row">
<div class="small-12 column v-space-short">
<h1 itemprop="name">[% title %]</h1>
<h1 itemprop="name">[% title %]
<sup>
[% IF request.tagtype == "categories" %]
<a class="button tiny round secondary label" href="https://hunger.openfoodfacts.org/questions?type=category&amp;value_tag=[% request.canon_tagid %]">[% f_lang('f_help_categorize_on_hunger_games', { title => lang('categories').lcfirst } ) %]</a>
[% ELSIF request.tagtype == "labels" %]
<a class="button tiny round secondary label" href="https://hunger.openfoodfacts.org/questions?type=labels&amp;value_tag=[% canonicalize_taxonomy_tag_link("labels", title) %]">[% f_lang('f_help_categorize_on_hunger_games', { title => lang('labels').lcfirst } ) %]</a>
[% ELSIF request.tagtype == "brands" %]
<a class="button tiny round secondary label" href="https://hunger.openfoodfacts.org/questions?type=brands&amp;value_tag=[% canonicalize_taxonomy_tag_link("brands", title) %]">[% f_lang('f_help_categorize_on_hunger_games', { title => lang('brands').lcfirst } ) %]</a>
[% END %]
</sup>
</h1>
</div>
</div>
[% content %]
Expand Down Expand Up @@ -288,7 +298,6 @@ <h1>[% title %]</h1>
</div>

[% INCLUDE 'web/common/includes/donate_banner_bottom.tt.html' %]

<div class="block_light block_cappucino" id="contribute_and_discover_links_block">
<div class="row">
<div class="small-12 large-6 columns v-space-normal block_off">
Expand Down

0 comments on commit 4a3b9d5

Please sign in to comment.