Skip to content

Commit

Permalink
[pull] main from openfoodfacts:main (#1169)
Browse files Browse the repository at this point in the history
* More packaging shapes (openfoodfacts#5608)

* packaging-fix-for-pains-de-mie

packaging-fix-for-pains-de-mie

* Update packaging_shapes.txt

* Update packaging_shapes.txt

* Update packaging_shapes.txt

* Update packaging_shapes.txt

* Update packaging_shapes.txt

* Update packaging_shapes.txt

* Update packaging_shapes.txt

* Update packaging_shapes.txt

* Update packaging_shapes.txt

* Update packaging_shapes.txt

* fix conflicting entries, add tests

* fix conflicting entries, add tests

Co-authored-by: Stéphane Gigandet <[email protected]>

* fix: Differentiate between rtl and ltr for the image position

* i18n: Make 'X g / 100 g' translatable (openfoodfacts#5655)

* i18n: Make 'X g / 100 g' translatable, especially for RTL languages

* fix: Use the old '%.2e' hack to format the decimals

* fix: Move selected packaging photos to new main language

Co-authored-by: Pierre Slamich <[email protected]>
Co-authored-by: Stéphane Gigandet <[email protected]>
Co-authored-by: hangy <[email protected]>
  • Loading branch information
4 people authored Sep 12, 2021
1 parent f2aac38 commit 314f112
Show file tree
Hide file tree
Showing 9 changed files with 250 additions and 24 deletions.
2 changes: 1 addition & 1 deletion cgi/product_multilingual.pl
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@

# Selected photos

foreach my $imageid ("front", "ingredients", "nutrition") {
foreach my $imageid ("front", "ingredients", "nutrition", "packaging") {

my $from_imageid = $imageid . "_" . $from_lc;
my $to_imageid = $imageid . "_" . $product_lc;
Expand Down
11 changes: 5 additions & 6 deletions html/js/product-multilingual.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This file is part of Product Opener.
//
// Product Opener
// Copyright (C) 2011-2020 Association Open Food Facts
// Copyright (C) 2011-2021 Association Open Food Facts
// Contact: [email protected]
// Address: 21 rue des Iles, 94100 Saint-Maur des Fossés, France
//
Expand Down Expand Up @@ -400,17 +400,16 @@ $.fn.isVisible = function() {
return $.expr.filters.visible(this[0]);
};
function update_nutrition_image_copy() {

// width big enough to display a copy next to nutrition table?
if ($("#nutrition_data_table").isVisible() && $('#nutrition').width() - $('#nutrition_data_table').width() > 405) {
$('#nutrition_image_copy').css("left", $('#nutrition_data_table').width() + 10).show();
if ($("#nutrition_data_table").isVisible() && $('#nutrition').width() - $('#nutrition_data_table').width() > 405) {
var position = $('html[dir=rtl]').length ? 'right' : 'left';
$('#nutrition_image_copy').css(position, $('#nutrition_data_table').width() + 10).show();
}
else {
$('#nutrition_image_copy').hide();
}
}


function update_display(imagefield, first_display) {

var display_url = imagefield_url[imagefield];
Expand Down Expand Up @@ -1230,4 +1229,4 @@ $("#move_images").click({},function(event) {

}

});
});
7 changes: 5 additions & 2 deletions lib/ProductOpener/Attributes.pm
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is part of Product Opener.
#
# Product Opener
# Copyright (C) 2011-2020 Association Open Food Facts
# Copyright (C) 2011-2021 Association Open Food Facts
# Contact: [email protected]
# Address: 21 rue des Iles, 94100 Saint-Maur des Fossés, France
#
Expand Down Expand Up @@ -1122,7 +1122,10 @@ sub compute_attribute_nutrient_level($$$$) {
if ($target_lc ne "data") {
$attribute_ref->{title} = sprintf(lang_in_other_lc($target_lc, "nutrient_in_quantity"), $Nutriments{$nid}{$target_lc} ,
lang_in_other_lc($target_lc, $product_ref->{nutrient_levels}{$nid} . "_quantity"));
$attribute_ref->{description_short} = (sprintf("%.2e", $product_ref->{nutriments}{$nid . $prepared . "_100g"}) + 0.0) . " g / 100 g";
$attribute_ref->{description_short} = sprintf(
lang_in_other_lc($target_lc, 'g_per_100g'),
(sprintf('%.2e', $product_ref->{nutriments}{$nid . $prepared . '_100g'}) + 0.0)
);
}
}
}
Expand Down
6 changes: 5 additions & 1 deletion po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -5707,4 +5707,8 @@ msgstr "impact"

msgctxt "nutrition_grade_fr_tea_bags_note"
msgid "Note: the Nutri-Score of teas and herbal teas corresponds to the product prepared with water only, without sugar or milk."
msgstr "Note: the Nutri-Score of teas and herbal teas corresponds to the product prepared with water only, without sugar or milk."
msgstr "Note: the Nutri-Score of teas and herbal teas corresponds to the product prepared with water only, without sugar or milk."

msgctxt "g_per_100g"
msgid "%s g / 100 g"
msgstr "%s g / 100 g"
4 changes: 4 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -5721,3 +5721,7 @@ msgstr "medium"
msgctxt "nutrition_grade_fr_tea_bags_note"
msgid "Note: the Nutri-Score of teas and herbal teas corresponds to the product prepared with water only, without sugar or milk."
msgstr "Note: the Nutri-Score of teas and herbal teas corresponds to the product prepared with water only, without sugar or milk."

msgctxt "g_per_100g"
msgid "%s g / 100 g"
msgstr "%s g / 100 g"
31 changes: 31 additions & 0 deletions t/expected_test_results/packaging/packaging_en_citeo_shapes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"lc" : "en",
"packaging" : "Plastic tumbler, Wooden crate, Cardboard case, Strings, Plastic ties, Plastic blister wrap, paper basket, individual capsules",
"packagings" : [
{
"material" : "en:plastic",
"shape" : "en:blister"
},
{
"shape" : "en:individual-dose"
},
{
"material" : "en:plastic",
"shape" : "en:tumbler"
},
{
"material" : "en:cardboard",
"shape" : "en:case"
},
{
"shape" : "en:crate"
},
{
"material" : "en:paper",
"shape" : "en:basket"
},
{
"shape" : "en:string"
}
]
}
32 changes: 32 additions & 0 deletions t/expected_test_results/packaging/packaging_fr_citeo_shapes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"lc" : "fr",
"packaging" : "Gobelet en plastique, cageots en bois, caisse en carton, ficelle, liens plastiques, blister en plastique, panier en papier, capsules individuelles",
"packagings" : [
{
"shape" : "en:capsule"
},
{
"material" : "en:plastic",
"shape" : "en:blister"
},
{
"material" : "en:plastic",
"shape" : "en:tumbler"
},
{
"material" : "en:cardboard",
"shape" : "en:case"
},
{
"material" : "en:paper",
"shape" : "en:basket"
},
{
"material" : "en:wood",
"shape" : "en:crate"
},
{
"shape" : "en:string"
}
]
}
18 changes: 17 additions & 1 deletion t/packaging.t
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,23 @@ my @tests = (
lc => "fr",
packaging => "1 support carton",
}
],
],

# New packaging shapes from Citeo
[
'packaging_en_citeo_shapes',
{
lc => "en",
packaging => "Plastic tumbler, Wooden crate, Cardboard case, Strings, Plastic ties, Plastic blister wrap, paper basket, individual capsules",
}
],
[
'packaging_fr_citeo_shapes',
{
lc => "fr",
packaging => "Gobelet en plastique, cageots en bois, caisse en carton, ficelle, liens plastiques, blister en plastique, panier en papier, capsules individuelles",
}
],
);

init_packaging_taxonomies_regexps();
Expand Down
Loading

0 comments on commit 314f112

Please sign in to comment.