From 70137a8a0c525366bda01b0b59aba458c3390db1 Mon Sep 17 00:00:00 2001 From: Amit Gupta Date: Mon, 17 Jan 2011 16:03:39 +0530 Subject: [PATCH] Bug-5621 Google Translation for indian languages. --- C4/Auth.pm | 1 + installer/data/mysql/updatedatabase.pl | 7 +++++ .../prog/en/modules/admin/preferences/opac.pref | 7 +++++ .../opac-tmpl/prog/en/js/googletransliteration.js | 29 ++++++++++++++++++++ opac/opac-main.pl | 5 --- opac/opac-search.pl | 5 --- 6 files changed, 44 insertions(+), 10 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/googletransliteration.js diff --git a/C4/Auth.pm b/C4/Auth.pm index b6ec69a..4f0c5d4 100644 --- a/C4/Auth.pm +++ b/C4/Auth.pm @@ -458,6 +458,7 @@ sub get_template_and_user { ShowReviewerPhoto => C4::Context->preference("ShowReviewerPhoto"), suggestion => "" . C4::Context->preference("suggestion"), virtualshelves => "" . C4::Context->preference("virtualshelves"), + GoogleTransliteration => C4::Context->preference("GoogleTransliteration"), OPACSerialIssueDisplayCount => C4::Context->preference("OPACSerialIssueDisplayCount"), OpacAddMastheadLibraryPulldown => C4::Context->preference("OpacAddMastheadLibraryPulldown"), OPACXSLTDetailsDisplay => C4::Context->preference("OPACXSLTDetailsDisplay"), diff --git a/installer/data/mysql/updatedatabase.pl b/installer/data/mysql/updatedatabase.pl index 8fb9656..5b68710 100755 --- a/installer/data/mysql/updatedatabase.pl +++ b/installer/data/mysql/updatedatabase.pl @@ -4370,6 +4370,13 @@ if (C4::Context->preference("Version") < TransformToNum($DBversion)) { SetVersion($DBversion); } +$DBversion = '3.05.00.XXX'; +if (C4::Context->preference("Version") < TransformToNum($DBversion)) { + $dbh->do("INSERT INTO `systempreferences` (variable,value,explanation,options,type) VALUES('GoogleTransliteration','0','Show GoogleTransliteration on the OPAC Masthead.', '','YesNo')"); + print "Upgrade to $DBversion done (Add GoogleTransliteration on opac page)\n"; + SetVersion ($DBversion); +} + =head1 FUNCTIONS =head2 DropAllForeignKeys($table) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref index f4be568..b2faf2d 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/opac.pref @@ -1,4 +1,11 @@ OPAC: + GoogleTransliteration: + - + - pref: GoogleTransliteration + choices: + yes: Show + no: "Don't show" + - Show GoogleTransliteration on the OPAC Masthead. Appearance: - - Use the diff --git a/koha-tmpl/opac-tmpl/prog/en/js/googletransliteration.js b/koha-tmpl/opac-tmpl/prog/en/js/googletransliteration.js new file mode 100644 index 0000000..5672d43 --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/js/googletransliteration.js @@ -0,0 +1,29 @@ + // Load the Google Transliteration API + google.load("elements", "1", { + packages: "transliteration" + }); + + function onLoad() { + var options = { + sourceLanguage: 'en', + destinationLanguage: ['hi','kn','ml','ta','te','ar','ur','pa','fa','bn'], + shortcutKey: 'ctrl+g', + transliterationEnabled: false + }; + + // Create an instance on TransliterationControl with the required + // options. + var control = + new google.elements.transliteration.TransliterationControl(options); + + // Enable transliteration in the textfields with the given ids. + var ids = [ "transl1" ]; + control.makeTransliteratable(ids); + + // Show the transliteration control which can be used to toggle between + // English and Hindi and also choose other destination language. + control.showControl('translControl'); + } + google.setOnLoadCallback(onLoad); + + diff --git a/opac/opac-main.pl b/opac/opac-main.pl index 177d812..166f918 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -90,9 +90,4 @@ $template->param( koha_news_count => $koha_news_count ); -# If GoogleIndicTransliteration system preference is On Set paramter to load Google's javascript in OPAC search screens -if (C4::Context->preference('GoogleIndicTransliteration')) { - $template->param('GoogleIndicTransliteration' => 1); -} - output_html_with_http_headers $input, $cookie, $template->output; diff --git a/opac/opac-search.pl b/opac/opac-search.pl index 7f247c7..2921f66 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -669,9 +669,4 @@ if (defined $barshelves) { my $content_type = ($format eq 'rss' or $format eq 'atom') ? $format : 'html'; -# If GoogleIndicTransliteration system preference is On Set paramter to load Google's javascript in OPAC search screens -if (C4::Context->preference('GoogleIndicTransliteration')) { - $template->param('GoogleIndicTransliteration' => 1); -} - output_with_http_headers $cgi, $cookie, $template->output, $content_type; -- 1.7.4.1