Use Google Indic Transliteration API to allow users to transliterate english typed...
authorsavitra.sirohi <savitra.sirohi@osslabs.biz>
Thu, 4 Jun 2009 10:37:14 +0000 (16:07 +0530)
committerGalen Charlton <galen.charlton@liblime.com>
Fri, 5 Jun 2009 23:05:47 +0000 (18:05 -0500)
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>
koha-tmpl/opac-tmpl/prog/en/css/opac.css
koha-tmpl/opac-tmpl/prog/en/includes/doc-head-close.inc
koha-tmpl/opac-tmpl/prog/en/includes/masthead.inc
koha-tmpl/opac-tmpl/prog/en/js/googleindictransliteration.js [new file with mode: 0644]
opac/opac-main.pl
opac/opac-search.pl

index de320d6..0c5c8d6 100644 (file)
@@ -1097,6 +1097,11 @@ float : right;
 width: 100%;
 }
 
+#translControl{
+float : left;
+padding-left : .4em;
+}
+
 .clearfix:after {
     content: "."; 
     display: block; 
index 2238fba..eeed1a5 100644 (file)
@@ -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 -->
+
index b118d18..058615b 100644 (file)
@@ -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" --> 
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 (file)
index 0000000..414cadd
--- /dev/null
@@ -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);
+
+
index 5a56db0..1f4d8d5 100755 (executable)
@@ -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;
index ae7f4ea..e1e66a9 100755 (executable)
@@ -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;