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 <galen.charlton@liblime.com>
This commit is contained in:
parent
b3fca95a7e
commit
6ae7b60962
6 changed files with 51 additions and 2 deletions
|
@ -1097,6 +1097,11 @@ float : right;
|
|||
width: 100%;
|
||||
}
|
||||
|
||||
#translControl{
|
||||
float : left;
|
||||
padding-left : .4em;
|
||||
}
|
||||
|
||||
.clearfix:after {
|
||||
content: ".";
|
||||
display: block;
|
||||
|
|
|
@ -80,3 +80,8 @@
|
|||
//]]>
|
||||
</script><!-- /TMPL_IF -->
|
||||
<link rel="unapi-server" type="application/xml" title="unAPI" href="<!-- TMPL_VAR NAME="OPACBaseURL" -->/cgi-bin/koha/unapi" />
|
||||
<!-- TMPL_IF NAME="GoogleIndicTransliteration" -->
|
||||
<script type="text/javascript" src="http://www.google.com/jsapi"></script>
|
||||
<script type="text/javascript" language="javascript" src="<!-- TMPL_VAR NAME="themelang" -->/js/googleindictransliteration.js"></script>
|
||||
<!-- /TMPL_IF -->
|
||||
|
||||
|
|
|
@ -55,9 +55,9 @@
|
|||
<option value="callnum">Call Number</option>
|
||||
<!-- /TMPL_IF --></select>
|
||||
<!-- TMPL_IF NAME="ms_value" -->
|
||||
<input type="text" name="q" value="<!-- TMPL_VAR ESCAPE="HTML" NAME="ms_value" -->" class="left" style="width: 35%; font-size: 111%;" />
|
||||
<input type="text" id = "transl1" name="q" value="<!-- TMPL_VAR ESCAPE="HTML" NAME="ms_value" -->" class="left" style="width: 35%; font-size: 100%;"/><div id="translControl"></div>
|
||||
<!-- TMPL_ELSE -->
|
||||
<input type="text" name="q" class="left" style="width: 35%; font-size: 111%;" />
|
||||
<input type="text" id = "transl1" name="q" class="left" style="width: 35%; font-size: 100%;"/><div id="translControl"></div>
|
||||
<!-- /TMPL_IF -->
|
||||
<!-- TMPL_UNLESS NAME="opac_limit_override" -->
|
||||
<!-- TMPL_IF name="mylibraryfirst" -->
|
||||
|
|
29
koha-tmpl/opac-tmpl/prog/en/js/googleindictransliteration.js
Normal file
29
koha-tmpl/opac-tmpl/prog/en/js/googleindictransliteration.js
Normal file
|
@ -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);
|
||||
|
||||
|
|
@ -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;
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in a new issue