From 6ae7b60962e7d07aa00a45a7af692939a4ce7aa6 Mon Sep 17 00:00:00 2001 From: "savitra.sirohi" Date: Thu, 4 Jun 2009 16:07:14 +0530 Subject: [PATCH] Use Google Indic Transliteration API to allow users to transliterate english typed words into Indic languages. This is available only on the masthead search box in the OPAC. User has to enter a word in english and press space or return to transliterate the word. The destination language can be selected from a drop down list. User can temporarily turn on/off the feature by using "ctrl +g". A system preference - GoogleIndicTransliteration can be used to turn on this feature. Signed-off-by: Galen Charlton --- koha-tmpl/opac-tmpl/prog/en/css/opac.css | 5 ++++ .../prog/en/includes/doc-head-close.inc | 5 ++++ .../opac-tmpl/prog/en/includes/masthead.inc | 4 +-- .../prog/en/js/googleindictransliteration.js | 29 +++++++++++++++++++ opac/opac-main.pl | 5 ++++ opac/opac-search.pl | 5 ++++ 6 files changed, 51 insertions(+), 2 deletions(-) create mode 100644 koha-tmpl/opac-tmpl/prog/en/js/googleindictransliteration.js diff --git a/koha-tmpl/opac-tmpl/prog/en/css/opac.css b/koha-tmpl/opac-tmpl/prog/en/css/opac.css index de320d6ca1..0c5c8d6ebf 100644 --- a/koha-tmpl/opac-tmpl/prog/en/css/opac.css +++ b/koha-tmpl/opac-tmpl/prog/en/css/opac.css @@ -1097,6 +1097,11 @@ float : right; width: 100%; } +#translControl{ +float : left; +padding-left : .4em; +} + .clearfix:after { content: "."; display: block; diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc index 2238fba449..eeed1a528e 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc @@ -80,3 +80,8 @@ //]]> /cgi-bin/koha/unapi" /> + + + + + diff --git a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc index b118d18e9c..058615b193 100644 --- a/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc +++ b/koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc @@ -55,9 +55,9 @@ - " class="left" style="width: 35%; font-size: 111%;" /> + " class="left" style="width: 35%; font-size: 100%;"/>
- +
diff --git a/koha-tmpl/opac-tmpl/prog/en/js/googleindictransliteration.js b/koha-tmpl/opac-tmpl/prog/en/js/googleindictransliteration.js new file mode 100644 index 0000000000..414cadd54e --- /dev/null +++ b/koha-tmpl/opac-tmpl/prog/en/js/googleindictransliteration.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'], + shortcutKey: 'ctrl+g', + transliterationEnabled: true + }; + + // 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 5a56db0387..1f4d8d5afc 100755 --- a/opac/opac-main.pl +++ b/opac/opac-main.pl @@ -56,4 +56,9 @@ $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 ae7f4ea37c..e1e66a9e94 100755 --- a/opac/opac-search.pl +++ b/opac/opac-search.pl @@ -640,4 +640,9 @@ if ($cgi->param('format') && $cgi->param('format') =~ /rss/) { $content_type = '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; -- 2.39.2