English to Tamil Translator script


Hi friends,

Started creating translator script in ruby,

which will convert to english document file to tamil pdf file.

Main idea of script is to convert English pdf to Tamil Pdf

So its easy to translate e-book easily to our mother tongue language.’

I just now started with tamil font. This will translate English doc to

Tamil using google translator http://translate.google.com/

Current Status:

*Now it gets .doc extension file from user and it converts to tamil pdf.

Need to changed as English pdf to Tamil pdf.

Note: It has many grammar mistakes while translating. and this is translated to tamil by http://translate.google.com/ Code was in github account : https://github.com/sathia27/Translate-script

If you like to start working in this code. You can take code form github acconut.

If you feel any good method other than this, Please give me suggestion.

Thank you in advance.


#!/usr/bin/env ruby
=begin
Program name: Translation script
Date Written: 05/12/2011
Date Modified: 05/12/2011
Author : Sathianarayanan.S
License: GPL2.0
Version: 1.0
=end
begin
 require 'rubygems'
 require 'nokogiri'
 require 'open-uri'
 require 'net/http'
 require 'uri'
 require 'prawn'
 if ARGV[0]
 puts "converting file '"+ARGV[0]+"' to tamil version!!!"
 resume = File.open(ARGV[0]);
 total_text = ""
 resume.each do |str|
 total_text += str
 end
 page = Nokogiri::HTML(open(URI.parse(URI.encode("http://translate.google.com/?langpair=en|ta&text=#{total_text}"))))
 puts resume.readlines
 result = page.search("#result_box")
 Prawn::Document.generate("output.pdf") do
 font "ttf-tamil-fonts/TAMu_Kalyani.ttf"
 text result.text, :size => 20
 end
 else
 puts "Enter file name. Filename can be .doc or .txt \n[Usage] ruby translate.rb filename.doc"
 end
end

Advertisements

About sathia

Web developer at cloudmint
This entry was posted in programs, ubuntu and tagged , , , , , , , , . Bookmark the permalink.

7 Responses to English to Tamil Translator script

  1. Shrini Vasan says:

    Great Start.

    Wishes.

  2. Not Working 4 me 😦
    ruby training/translator.rb /home/logan/notes/mysqltips.txt
    WARNING: Nokogiri was built against LibXML version 2.7.5, but has dynamically loaded 2.7.6
    converting file ‘/home/natchiar/notes/mysqltips.txt’ to tamil version!!!
    /usr/lib/ruby/1.8/net/protocol.rb:177:in `write’: Broken pipe (Errno::EPIPE)
    from /usr/lib/ruby/1.8/net/protocol.rb:177:in `write0′
    from /usr/lib/ruby/1.8/net/protocol.rb:153:in `write’
    from /usr/lib/ruby/1.8/net/protocol.rb:168:in `writing’
    from /usr/lib/ruby/1.8/net/protocol.rb:152:in `write’
    from /usr/lib/ruby/1.8/net/http.rb:1578:in `write_header’
    from /usr/lib/ruby/1.8/net/http.rb:1533:in `exec’
    from /usr/lib/ruby/1.8/net/http.rb:1048:in `request’
    from /usr/lib/ruby/1.8/open-uri.rb:248:in `open_http’
    from /usr/lib/ruby/1.8/net/http.rb:543:in `start’
    from /usr/lib/ruby/1.8/open-uri.rb:242:in `open_http’
    from /usr/lib/ruby/1.8/open-uri.rb:616:in `buffer_open’
    from /usr/lib/ruby/1.8/open-uri.rb:164:in `open_loop’
    from /usr/lib/ruby/1.8/open-uri.rb:162:in `catch’
    from /usr/lib/ruby/1.8/open-uri.rb:162:in `open_loop’
    from /usr/lib/ruby/1.8/open-uri.rb:132:in `open_uri’
    from /usr/lib/ruby/1.8/open-uri.rb:518:in `open’
    from /usr/lib/ruby/1.8/open-uri.rb:26:in `open’

  3. SATHEES says:

    THANK YOU…………….

  4. kedar says:

    i used this code to translate the code in portugis

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s