This app will help you to translate any language supported by Google translation API from one to another. The best thing about this app is you don't need any subscription(:wink:), you just need Google account to host the script provided below:point_down:.
function doGet(e) {
var sourceText = '';
if (e.parameter.q) {
sourceText = e.parameter.q;
}
var sourceLang = 'auto';
if (e.parameter.source) {
sourceLang = e.parameter.source;
}
var targetLang = 'ja';
if (e.parameter.target) {
targetLang = e.parameter.target;
}
var translatedText = LanguageApp.translate(sourceText, sourceLang, targetLang);
var json = {
translatedText: translatedText,
};
// set JSONP callback
var callback = 'callback';
if (e.parameter.callback) {
callback = e.parameter.callback;
}
// return JSONP
return ContentService.createTextOutput(JSON.stringify(json)).setMimeType(
ContentService.MimeType.JSON
);
}
- JavaFX for UI.
- Maven for dependency management.
- Unirest for making an HTTP request to Google translation API.
- Host the provided script
- Got to Google Apps Script ->Click
Start Scripting
. - Create
New project
and replace everything in the editor with the provied script. - Click
Deploy
->New Deployment
-> Click the gear icon on the top left corner of the popup. - Select Web app -> Fill all fields and choose
Anyone
for the fieldWho has access
. - Copy the generate
Web App
url. - Goto
language-translator/src/main/resources/application.properties
and assign the url totranslator.api.wep-app.url
field.
- Got to Google Apps Script ->Click
- Run the application
- You need to have jdk installed in your pc and JAVA_HOME configured in enviroment variables.
- Download Maven and configure M2_HOME in enviroment variables.
- Clone this repository to your pc
- Open the project in you favorite IDE and run it.
- After running it you will notice an executable jar file is created in
target
folder. You can use this jar file on any computer as long as the appropriate JDK is installed.