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

fix: Added a description line to the import spreadsheet template #9920

Merged
merged 7 commits into from
Mar 15, 2024
Merged
12 changes: 10 additions & 2 deletions cgi/generate_sample_import_file.pl
Original file line number Diff line number Diff line change
Expand Up @@ -59,13 +59,21 @@
mandatory => $workbook->add_format(border => 1, bold => 1, bg_color => '#aaffcc'),
recommended => $workbook->add_format(border => 1, bold => 1, bg_color => '#ccffdd'),
optional => $workbook->add_format(border => 1, bold => 1, bg_color => '#eeffee'),
description => $workbook->add_format(italic => 1, text_wrap => 1, align => 'left', align => 'vcenter'),
);

# Re-use the structure used to output select2 options in import_file_select_format.pl
my $select2_options_ref = generate_import_export_columns_groups_for_select2([$lc]);

my $headers_row = 0;
my $col = 0;
my $description_row = 1;
my $col = 1;

my $field_id;
my $comment;

$worksheet->set_column('A:A', 30);
$worksheet->write( $description_row, 0, "Description", $formats{'description'});
Copy link
Contributor

Choose a reason for hiding this comment

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

Could you make "Description" a translatable string?

To do that, you need to put lang("description") instead, and then add a stringid "description" in po/common.po and po/en.po (and it would be good to add it in another language so that you can test that you get a different string if you load for instance the site in Spanish: http://es.openfoodfacts.localhost/cgi/generate_sample_import_file.pl

Once you have added / changed a string in po/common.pot / en.po / es.po , you need to run:
make build_lang
make restart

and then you can use lang("description") in the Perl file instead of "Description".

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi @stephanegigandet,

Yes, I can. But I don't understand if I should add it as stringid or as msid, like in the po/common.po file?

Screenshot 2024-03-15 at 15 10 12

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Followed the instructions and turned "Description" into a translatable string

Copy link
Contributor

Choose a reason for hiding this comment

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

@anaritadauane Great :)

Can you also add this to en.po so that we have an English translation (English is the default):

msgctxt "description"
msgid "Description"
msgstr "Description"

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done


foreach my $group_ref (@$select2_options_ref) {
my $group_start_col = $col;
Expand Down Expand Up @@ -184,7 +192,7 @@
$worksheet->set_column($col, $col, $width);

if ($comment ne "") {
$worksheet->write_comment($headers_row, $col, $comment);
$worksheet->write($description_row, $col, $comment, $formats{'description'});
}

$col++;
Expand Down
Loading