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

Optimize functions to display tags and add inline translation of taxonomies #1724

Merged
merged 25 commits into from
Apr 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
274667e
new get_taxonomy_tag_and_link_for_lang to replace multiple calls to d…
stephanegigandet Mar 14, 2019
50ba499
save translations for taxonomies
Mar 23, 2019
243adc4
translate_list_of_tags
Mar 23, 2019
3a9a025
Add javascript to call /cgi/translate_taxonomy.pl to save translation…
Mar 25, 2019
5126c6c
Merge branch 'master' into tags-functions
Mar 25, 2019
717a6ba
inline translation for taxonomies, bug #1721
Mar 26, 2019
5d93d99
update additives taxonomy
Mar 26, 2019
1e7260d
inline translation for taxonomies, bug #1721
Mar 26, 2019
929c753
change line endings to unix line feeds
Mar 26, 2019
b7aed25
update category taxonomy
Mar 26, 2019
c5d4b5f
update label taxonomy
Mar 26, 2019
e90157b
reorder translations alphabetically with add_users_translations_to_ta…
Mar 26, 2019
a2ebfe0
fix users translations
Mar 26, 2019
96d922e
incorporate users translations
Mar 26, 2019
fa70029
Merge branch 'master' into tags-functions
Mar 26, 2019
6d93d10
new strins for users translations
Mar 26, 2019
e109811
add google translate link for taxonomy translations
Mar 26, 2019
7d8c253
Merge branch 'master' into tags-functions
stephanegigandet Mar 28, 2019
942aa20
added new translations from users
stephanegigandet Mar 29, 2019
7fddf16
Merge branch 'master' into tags-functions
stephanegigandet Mar 29, 2019
5034c44
add translate=all option to change existing translations, bug #1721
stephanegigandet Apr 1, 2019
057072e
merge master in tags-functions
stephanegigandet Apr 1, 2019
bff37bb
Merge branch 'master' into tags-functions
stephanegigandet Apr 1, 2019
f6eeb10
Merge branch 'master' into tags-functions
stephanegigandet Apr 2, 2019
0201708
fix failing test (apples went bananas)
stephanegigandet Apr 4, 2019
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
63 changes: 63 additions & 0 deletions cgi/translate_taxonomy.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/usr/bin/perl -w

# This file is part of Product Opener.
#
# Product Opener
# Copyright (C) 2011-2019 Association Open Food Facts
# Contact: contact@openfoodfacts.org
# Address: 21 rue des Iles, 94100 Saint-Maur des Fossés, France
#
# Product Opener is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.

use Modern::Perl '2012';
use utf8;

use CGI::Carp qw(fatalsToBrowser);

use ProductOpener::Config qw/:all/;
use ProductOpener::Store qw/:all/;
use ProductOpener::Lang qw/:all/;
use ProductOpener::Display qw/:all/;
use ProductOpener::Tags qw/:all/;
use ProductOpener::Users qw/:all/;

use Encode;
use CGI qw/:cgi :form escapeHTML/;
use Log::Any qw($log);
use JSON::PP;

ProductOpener::Display::init();

my $tagtype = remove_tags_and_quote(decode utf8=>param('tagtype'));
my $from = remove_tags_and_quote(decode utf8=>param('from'));
my $to = remove_tags_and_quote(decode utf8=>param('to'));

my $status;

if ((defined $tagtype) and (defined $from) and (defined $to) and ($to ne "")) {
$status = "ok";
add_user_translation($lc, $tagtype, $User_id, $from, $to);
}
else {
$status = "not ok - missing tagtype, from or to parameter";
}

my $data = encode_json({ status => $status });

$log->debug("JSON data output", { data => $data }) if $log->is_debug();

print header( -type => 'application/json', -charset => 'utf-8' ) . $data;

exit(0);

Loading