Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

I have an idea for a Perl module.

I would like to be able to produce web sites that hold Java Script that enable the user to select a language and when the user mouse-overs an English word the translation of that word is shown in a language of the user's choice i.e. the translation would appear in a little yellow box. Has anyone seen this previously?

The Java script would only have to contain lookup tables for words that are on that web site. So the module would take HTML files and produce a new version of the web page with extra JavaScript to enable the word translations. Has anyone else thought about this? Is there such software that is commercially available?

Replies are listed 'Best First'.
Re: Java script generation module
by belg4mit (Prior) on Feb 11, 2005 at 15:59 UTC
    You asked in the CB and castway said she was familiar with something like this. But in any event, you have two ideas, and not much detail about the perl thing you actually want. In any event, two replies:
    1. A dictionary is rather large thing to dump into a page
    2. There are modules to do what would be necessary such as Data::JavaScript/Data::JavaScript

      --
      I'm not belgian but I play one on TV. On dit que je parle comme un belge aussi.

      I propose having the dictionaries within the module. The translations for a range of languages would be specific to the web page ie. there would be no redundancy. I think that it is a great idea
Re: Java script generation module
by Jaap (Curate) on Feb 11, 2005 at 16:45 UTC
    You could do something like Google Suggest: do a SOAP/XML-RPC request from the (javascript) client when you want the translation of a word. You'd need a general dictionary service on your server.
Re: Java script generation module
by TedPride (Priest) on Feb 11, 2005 at 18:12 UTC
    I like Javascript, but this is not something I'd use it for. Better to have different versions of the page, one for each language, or generate the page dynamically depending on which language is chosen. Javascript is feasible, assuming a limited number of languages and words per page, but people aren't going to want to have to mouseover to read the page in their own language.
      Just three things, that might help you:
      • Javascript is not so popular nowadays as you would imagine. So you might simply put the word translation inside a title attribute (See HTML spec) before loading the page (serverside).
      • You could determine the users language by having an IP-Country table-map related with their prefered language (from those that you provide). If the users native language is the same as the original text, then you could save the time of translating the page (it should also, save a lot of memory).
      • You shouldn't face it as a translation resource (that is much more complex), but as a help guide, for people whose mother tongue is different than that of the page.
      You should always provide an option for having the page displayed without any translation before accessing the mentioned page (and keep the option in a cookie).

      Here is a link for further info-ideas: http://www.cpanforum.com/dist/IP-Country

      No I think it's a great idea. The page is NOT translated to the other lang.(Would need grammar too)But to have a translation (espescially) of themespecific words is great.