Skip to content

Commit

Permalink
feat: add packaging parts fields to import template (#7775)
Browse files Browse the repository at this point in the history
  • Loading branch information
stephanegigandet authored Nov 30, 2022
1 parent d747479 commit a139e32
Show file tree
Hide file tree
Showing 9 changed files with 121 additions and 20 deletions.
16 changes: 7 additions & 9 deletions cgi/generate_sample_import_file.pl
Original file line number Diff line number Diff line change
Expand Up @@ -127,17 +127,15 @@
$comment .= lang("separate_values_with_commas") . "\n\n";
}

my $note = lang($field_id . "_note");
my $import_note = lang($field_id . "_import_note");
my $example = lang($field_id . "_example");

if ($note ne "") {
$comment .= lang($field_id . "_note") . "\n\n";
# Add notes that are defined in the .po files
foreach my $note_field ("note", "note_2", "note_3", "import_note") {
my $note = lang($field_id . "_" . $note_field);
if ($note ne "") {
$comment .= $note . "\n\n";
}
}

if ($import_note ne "") {
$comment .= lang($field_id . "_import_note") . "\n\n";
}
my $example = lang($field_id . "_example");

if ($example ne "") {

Expand Down
2 changes: 1 addition & 1 deletion cgi/product_multilingual.pl
Original file line number Diff line number Diff line change
Expand Up @@ -661,7 +661,7 @@ ($product_ref, $field, $language)
$value =~ s/\n/ /g;
}

foreach my $note ("_note", "_note_2") {
foreach my $note ("_note", "_note_2", "_note_3") {
if (defined $Lang{$fieldtype . $note}{$lang}) {

push(
Expand Down
13 changes: 6 additions & 7 deletions lib/ProductOpener/Config_off.pm
Original file line number Diff line number Diff line change
Expand Up @@ -723,7 +723,6 @@ $options{import_export_fields_groups} = [
"quantity_value_unit", "net_weight_value_unit",
"drained_weight_value_unit", "volume_value_unit",
"serving_size_value_unit", "packaging",
"packaging_text",
"brands", "brand_owner",
"categories", "categories_specific",
"labels", "labels_specific",
Expand All @@ -739,15 +738,15 @@ $options{import_export_fields_groups} = [
["ingredients", ["ingredients_text", "allergens", "traces"]],
["nutrition"],
["nutrition_other"],
["packaging"],
[
"other",
[
"nutriscore_score_producer", "nutriscore_grade_producer",
"nova_group_producer", "conservation_conditions",
"warning", "preparation",
"recipe_idea", "recycling_instructions_to_recycle",
"recycling_instructions_to_discard", "customer_service",
"link"
"conservation_conditions", "warning",
"preparation", "nutriscore_score_producer",
"nutriscore_grade_producer", "nova_group_producer",
"recipe_idea", "customer_service",
"link",
]
],
[
Expand Down
24 changes: 24 additions & 0 deletions lib/ProductOpener/Producers.pm
Original file line number Diff line number Diff line change
Expand Up @@ -1491,6 +1491,9 @@ JSON
my $group_id = $group_ref->[0];
my $select2_group_ref = {text => lang("fields_group_" . $group_id), children => [], group_id => $group_id};

# For some specific groups, we generate the corresponding lists of fields

# List of nutrients
if (($group_id eq "nutrition") or ($group_id eq "nutrition_other")) {

# Go through the nutriment table
Expand Down Expand Up @@ -1538,6 +1541,27 @@ JSON
};
}
}
# Packaging
if ($group_id eq "packaging") {
foreach
my $field ("packaging_text", "recycling_instructions_to_recycle", "recycling_instructions_to_discard")
{
my $name = lang($field);
push @{$select2_group_ref->{children}}, {id => "$field", text => ucfirst($name)};
}

for (my $i = 1; $i <= 5; $i++) {
my $packaging_i = lang("packaging_part_short") . " " . $i . " - ";
foreach
my $property ("number_of_units", "shape", "material", "recycling", "weight", "quantity_per_unit")
{
my $name = $packaging_i . lang("packaging_" . $property);
my $field = "packaging_${i}_{$property}";
push @{$select2_group_ref->{children}}, {id => "$field", text => ucfirst($name)};
}
}
}
# Other groups have fields listed directly in the $options{import_export_fields_groups} structure
else {

foreach my $field (@{$group_ref->[1]}) {
Expand Down
28 changes: 28 additions & 0 deletions po/common/common.pot
Original file line number Diff line number Diff line change
Expand Up @@ -4845,6 +4845,10 @@ msgctxt "packaging_text_note_2"
msgid "Try to be as specific as possible. For plastic, please indicate if it is opaque or transparent, colored, PET or PEHD."
msgstr "Try to be as specific as possible. For plastic, please indicate if it is opaque or transparent, colored, PET or PEHD."

msgctxt "packaging_text_note_3"
msgid "Data from this field will be combined with any data provided for each packaging part. It is possible to provide one or the other, or both."
msgstr "Data from this field will be combined with any data provided for each packaging part. It is possible to provide one or the other, or both."

msgctxt "product_js_extract_packaging"
msgid "Extract the recycling instructions and/or packaging information from the picture"
msgstr "Extract the recycling instructions and/or packaging information from the picture"
Expand Down Expand Up @@ -5100,6 +5104,11 @@ msgctxt "packaging_parts"
msgid "Packaging parts"
msgstr "Packaging parts"

# A short name for a physical piece of packaging (e.g. in English, "packaging" instead of "packaging part"). Used with a number (e.g. "Packaging 1" to identify a packaging part)
msgctxt "packaging_part_short"
msgid "Packaging"
msgstr "Packaging"

# Number of packaging parts
msgctxt "packaging_number"
msgid "Number"
Expand Down Expand Up @@ -6412,8 +6421,27 @@ msgctxt "api_impact_field_ignored"
msgid "Field ignored"
msgstr "Field ignored"

# Unit = element, not unit of measure
msgctxt "packaging_number_of_units"
msgid "Number of units"
msgstr "Number of units"

# Unit = element, not unit of measure
msgctxt "packaging_weight"
msgid "Weight of one empty unit"
msgstr "Weight of one empty unit"

# Unit = element, not unit of measure
msgctxt "packaging_quantity_per_unit"
msgid "Quantity of product contained per unit"
msgstr "Quantity of product contained per unit"

# 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"

msgctxt "packagings_complete"
msgid "All the packaging parts of the product are listed."
msgstr "All the packaging parts of the product are listed."

28 changes: 28 additions & 0 deletions po/common/en.po
Original file line number Diff line number Diff line change
Expand Up @@ -4916,6 +4916,10 @@ msgctxt "packaging_text_note_2"
msgid "Try to be as specific as possible. For plastic, please indicate if it is opaque or transparent, colored, PET or PEHD."
msgstr "Try to be as specific as possible. For plastic, please indicate if it is opaque or transparent, colored, PET or PEHD."

msgctxt "packaging_text_note_3"
msgid "Data from this field will be combined with any data provided for each packaging part. It is possible to provide one or the other, or both."
msgstr "Data from this field will be combined with any data provided for each packaging part. It is possible to provide one or the other, or both."

msgctxt "product_js_extract_packaging"
msgid "Extract the recycling instructions and/or packaging information from the picture"
msgstr "Extract the recycling instructions and/or packaging information from the picture"
Expand Down Expand Up @@ -5134,6 +5138,11 @@ msgctxt "packaging_parts"
msgid "Packaging parts"
msgstr "Packaging parts"

# A short name for a physical piece of packaging (e.g. in English, "packaging" instead of "packaging part"). Used with a number (e.g. "Packaging 1" to identify a packaging part)
msgctxt "packaging_part_short"
msgid "Packaging"
msgstr "Packaging"

# Number of packaging parts
msgctxt "packaging_number"
msgid "Number"
Expand Down Expand Up @@ -6419,7 +6428,26 @@ msgctxt "api_impact_field_ignored"
msgid "Field ignored"
msgstr "Field ignored"

# Unit = element, not unit of measure
msgctxt "packaging_number_of_units"
msgid "Number of units"
msgstr "Number of units"

# Unit = element, not unit of measure
msgctxt "packaging_weight"
msgid "Weight of one empty unit"
msgstr "Weight of one empty unit"

# Unit = element, not unit of measure
msgctxt "packaging_quantity_per_unit"
msgid "Quantity of product contained per unit"
msgstr "Quantity of product contained per unit"

# 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"

msgctxt "packagings_complete"
msgid "All the packaging parts of the product are listed."
msgstr "All the packaging parts of the product are listed."
26 changes: 25 additions & 1 deletion po/common/fr.po
Original file line number Diff line number Diff line change
Expand Up @@ -4711,6 +4711,10 @@ msgctxt "packaging_text_note_2"
msgid "Try to be as specific as possible. For plastic, please indicate if it is opaque or transparent, colored, PET or PEHD."
msgstr "Essayez d'être aussi précis que possible. Pour le plastique, merci d'indiquer s'il est opaque ou transparent, coloré, PET ou PEHD."

msgctxt "packaging_text_note_3"
msgid "Data from this field will be combined with any data provided for each packaging part. It is possible to provide one or the other, or both."
msgstr "Les données de ce champ seront combinées avec les éventuelles données fournies pour chaque élément d'emballage. Il est possible de fournir l'un ou l'autre, ou les deux."

msgctxt "product_js_extract_packaging"
msgid "Extract the recycling instructions and/or packaging information from the picture"
msgstr "Extraire les instructions de recyclage et/ou les informations d'emballage depuis l'image"
Expand Down Expand Up @@ -4962,9 +4966,15 @@ msgctxt "ecoscore_s"
msgid "Eco-Score"
msgstr "Éco-Score"

# Parts meaning individual elements
msgctxt "packaging_parts"
msgid "Packaging parts"
msgstr "Parties de l'emballage"
msgstr "Elements d'emballage"

# A short name for a physical piece of packaging (e.g. in English, "packaging" instead of "packaging part"). Used with a number (e.g. "Packaging 1" to identify a packaging part)
msgctxt "packaging_part_short"
msgid "Packaging"
msgstr "Emballage"

# Number of packaging parts
msgctxt "packaging_number"
Expand Down Expand Up @@ -6201,3 +6211,17 @@ msgctxt "environment"
msgid "Environment"
msgstr "Environnement"

# Unit = element, not unit of measure
msgctxt "packaging_number_of_units"
msgid "Number of units"
msgstr "Nombre d'éléments"

# Unit = element, not unit of measure
msgctxt "packaging_weight"
msgid "Weight of one empty unit"
msgstr "Poids d'un élément vide"

# Unit = element, not unit of measure
msgctxt "packaging_quantity_per_unit"
msgid "Quantity of product contained per unit"
msgstr "Quantité de produit contenue par élément"
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@
]
}
],
"title" : "Parties de l'emballage"
"title" : "Elements d'emballage"
}
}
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -425,7 +425,7 @@
]
}
],
"title" : "Parties de l'emballage"
"title" : "Elements d'emballage"
}
}
],
Expand Down

0 comments on commit a139e32

Please sign in to comment.