https://github.com/thinkphp/google-translate
This plugin MooTools works with the Google Language API and can be used to translate a text in all the languages provided by the API.
https://github.com/thinkphp/google-translate
Last synced: 3 months ago
JSON representation
This plugin MooTools works with the Google Language API and can be used to translate a text in all the languages provided by the API.
- Host: GitHub
- URL: https://github.com/thinkphp/google-translate
- Owner: thinkphp
- Created: 2011-02-19T17:29:38.000Z (almost 15 years ago)
- Default Branch: master
- Last Pushed: 2011-02-19T19:13:04.000Z (almost 15 years ago)
- Last Synced: 2024-04-14T14:54:25.718Z (almost 2 years ago)
- Language: PHP
- Homepage: http://thinkphp.ro/apps/js-hacks/google-translate/demos/demo1.html
- Size: 109 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
GoogleLanguage
==============
This plugin works with the Google Language API and can be used to translate a text in all the languages provided by the API.

How to use
----------
First you must to include the JS files in the head of your HTML document.
#HTML
In your JS.
#JS
window.addEvent('domready', function(){
//source language text
var from = "en",
//target language
to = "fr",
//grab the original text
text = document.id('input').get('value'),
//classical usage
try = new GoogleLanguage({text: text,from: from, to: to,
onRequest: function() {
//do something here while loading
},
onSuccess: function(resp) {
//put the translated text where you want.
document.id('results').set('text', resp);
}
});
document.id('trans').addEvent('click', function(){
try.translate();
});
//you can use setting up the element with setter and getter as below
$('text1').set('translate',{from: 'ro',
to:'en',
onRequest: function(){
//do something onLoading
},
onComplete: function(){
//do something when has completed
}
});
$('text1').addEvent('click', function(){
$('text1').translate();
});
$('text2').set('translate',{from: 'ro',
to:'en',
onRequest: function(){
//do something onLoading
},
onComplete: function(){
//do something when has completed
}
});
$('text2').addEvent('click', function(){
$('text2').translate();
});
});
In your HTML
#html
### Notes:
You can view in action:
- [http://thinkphp.ro/apps/js-hacks/google-translate/demos/demo1.html](http://thinkphp.ro/apps/js-hacks/google-translate/demos/demo1.html)
- [http://thinkphp.ro/apps/js-hacks/google-translate/demos/demo2.html](http://thinkphp.ro/apps/js-hacks/google-translate/demos/demo2.html)