ITRANS TRANSLATOR (Firefox Extension) - PROF. G. SIVAKUMAR AJIT BURAD (03005009) KSHITIJ BHARDWAJ (03005010) AMAN PARNAMI (03D05008)
←
→
Page content transcription
If your browser does not render page correctly, please read the page content below
ITRANS TRANSLATOR (Firefox Extension) A project under : PROF. G. SIVAKUMAR Group Members AJIT BURAD (03005009) KSHITIJ BHARDWAJ (03005010) AMAN PARNAMI (03D05008) Project site:> http://10.3.2.40/itrans/index.html
Objective : To design a Firefox extension which will convert selected itrans text to corresponding Indian languages and also provide an online interface for it. Languages used : 1) PHP , HTML ,XML 2)Java script 3)Shell script Overview : After the extension is installed it allows the user to select any itrans text on the current page and on right clicking displays the options regarding the target language . Once an option is selected translated text is displayed in a new page which includes an option to switch to Online interface .
Implementation : Our implementation runs in 3 stages : 1)Extension part . 2)Web server processing Itrans text . a) PHP module b) Shell script 3) Online interface . 1. EXTENSION PART Structure of an extension : Following figure gives hierarchial structure of a firefox extension :
1.1 Install.rdf : This is a Resource Description Framework File (rdf). It is needed by firefox to recognize an extension uniquely. It contains a key that should be different from that of all the installed extensions on the browser . It also contains a key of the target application (for ex . firefox,thunderbird etc.) . It specifies whether or not it can be installed on an application. It also contains information about the extension like creator,version and home page url . This is the information viewed when we right click on the extension in the extension's window of firefox and select the 'About' option.(Reference 5) 1.2 Chrome : This folder contain a Java Archive(.jar) . In our case it is Itrans.jar . On extracting this file we obtain following folders : a) Content b) Skin a) Content : This folder contains a single folder by the same name as that of java archive file . This folder contains files with extensions .js , .xul , .rdf . There can be other files too which are specific to an extension . In our case following files are there in this folder : itransOverlay.xul itransOverlay.js contents.rdf about.xul >itransOverlay.xul : This file contains the name of the javascript file in which the functions to which it makes a call are defined. In our extension it contains itransOverlay.xul. It is this file that contains the description for the menu of the extension in
the context menu. Like in our case we have an option by the name of Translator in the right click menu. And on taking the cursor to this, a submenu appears. This submenu has been defined in this file under the tag menupopup. Each of the item in this submenu has been defined as a menuitem. Each is associated with a keyword label. The value of the label gives the text which is displayed it the submenu. And each item is also associated with the keyword oncommand(). The value of this tag gives the functions which is to be called when this item is clicked in the submenu.(Reference 4) >itransOverlay.js : This contains definitions of the functions that are used by the extension. Our extension contains a function that appends the text selected in the browser to the appropriate url. The url is selected by the call made in the .xul file depending on which item in the submenu was clicked. There are functions which check whether the selected text is proper or not in the sense that it should not be an input field, textbox. Finally the function itrans_gotoWebService() which opens the url obtained after appending the text. >contents.rdf : This describes paths specific to firefox and extension. It also contains description about the author,the name of the extension and description about it. >about.xul : This contains information about the 'About' window that was discussed in Install.rdf section.The values of the fields are defined in the Install.rdf. b) Skin : It contains folder for various skins of the extension . Within these folders there must be a folder with the same name as that of the name of the java archive file in the content folder.This
folder must contain a contents.rdf file. It can also contain images used by the extension. From HelloWorld! to Itranslator v0.1 The first extension we started with was Helloworld!.(Reference 7) It was a simple extension which displayed HelloWorld! in an alert window when selected in context menu. Next we studied an extension by the name of simpledictionary. (Reference 6) It when installed added a text box to the browser toolbar. It searched the meaning of the word entered in an online dictionary and displayed it in a new tab. We modified it to convert the entered text into hindi by passing the selected text to our webserver.(configured for hindi only at that time) Then we tried implementing a popup menu when an option in the context menu is selected.And once this was done we modified the code to add more languages for translation.To implement this we modified the functions in the itransOverlay.js file at the same time changing the itransOverlay.xul file to get more options in the popup menu. Finally, we added an option for online interface in the popup menu.
2. WEB SERVER PROCESSING ITRANS TEXT : Firstly, we installed itrans supporting different indian languages and fonts to be used in Latex(.tex) to Postscript(.ps) file conversion . We also used Latex(.tex) to Html(.html) and Postscript(.ps) to Image(.png) conversion. We used a .PHP file to pass the selected text and opted language from the extension to a shell script ,which first creates an itrans(.itx) file and then carries out following conversions in specified order .(Reference 8)
Order of conversion : 1) Itrans(.itx) to Latex(.tex) 2) Latex(.tex) to Postscript(.ps) 3) Postscript(.ps) to Image(.png) This script also exports paths used by different commands (for ex. dvips, latex2html etc) to font files used . While Postscript to Image conversion we first magnified the image and then cropped the extra spaces . We then embedded this image into an Html page . This page also contains a link to the online interface (Reference 1) which will be discussed in later portion of report. Problem Faced : ● Installation Itrans : The dvips was not able to find proper paths for font files. The problem was solved by placing DVIPSRC appropriately in user's home directory with name .dvipsrc . Also adding paths of fonts for indian languages in psfont.map. ● Accessing Itrans & dvips command by an web user was giving error. so these commands were run by calling sudo (i.e. with root permission for specific file) using exec() PHP which is used to call system commands by PHP files.
Installing extension: Drag the extension to Firefox after saving it to our system.
Online Interface This is a web page hosted on the same server . It provides user a means of translating itrans text of his choice to specified Indian language.
References : 1. http://www.aczoom.com/itrans/online/ 2. http://businesslogs.com/technology/firefox_extension_tutorial.php 3. http://mesh.typepad.com/blog/firefox_development/ 4. http://www.xulplanet.com/tutorials/xultu/ 5. http://www.bengoodger.com/software/mb/extensions/howto.html 6. https://addons.update.mozilla.org/extensions/?application=firefox 7. http://roachfiend.com/archives/2004/12/08/howtocreatefirefox extensions/ 8. http://www.php.net/
You can also read