Skip to content

doomedcat17/open-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

open-translator

Free Google Translator library for Java.

This project is basically a re-write of therealbush/translator from Kotlin to Java 11. If you don't need pure Java library, use therealbush's translator.

What is this?

Simple Java library that uses Google Translate Ajax API free translations. API token is not required.

I needed some translations of one of my personal projects and found therealbush/translator. It works fine, but I needed pure Java library to customize WebClient.

Installation

Maven

Add JitPack to your project repos:

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>

And then add following dependency:

<dependency>
    <groupId>com.github.doomedcat17</groupId>
    <artifactId>open-translator</artifactId>
    <version>1.0.0</version>
</dependency>

Gradle

Add JitPack to your project repos:

allprojects {
    repositories {
        maven { url 'https://jitpack.io' }
    }
}

And then add following dependency:

dependencies {
    implementation 'com.github.doomedcat17:open-translator:Tag'
}

Usage

Create instance of Translator class:

Translator translator = new Translator();

And translate some text:

Translation translation = translator.translate("Witaj Świecie!", Language.ENGLISH);
System.out.println(translation.getTranslatedText()); // Hello World!

The maximum character limit on a single text is 15k.

Alternatively, you can create Translator using your own WebClient implementation :3.

If something goes wrong, TranslatorException is thrown.

Important notes

This is an unofficial library using web API of Google translator and is not associated with Google. Official API is available here.

Remember that abuse of the library can end with an IP ban from Google. For more data to be translated, I recommend using a proxy.

About

Free Google Translator library for Java.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages