Code Monkey home page Code Monkey logo

yandex-translate-api's Introduction

Yandex Translate API

License Codacy Badge Coverage Status Build Status

yandex-translate-api is a simple REST client library for Yandex.Translate. The API provides access to the Yandex online machine translation service. It supports more than 90 languages and can translate separate words or complete texts.

Online documentation: Javadoc

Prerequisites

The following actions are required to work with this library:

  • Install JDK 1.8
  • Get a free API key.

Setup

Gradle configuration:

repositories {
    maven {
        url "https://jitpack.io"
    }
}

dependencies {
    compile 'com.github.vbauer:yandex-translate-api:1.4.2'
}

Maven configuration:

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

<dependency>
    <groupId>com.github.vbauer</groupId>
    <artifactId>yandex-translate-api</artifactId>
    <version>1.4.2</version>
</dependency>

Usage

FYI:

The entry point of this library is YTranslateApi interface (and the corresponding implementation YTranslateApiImpl).

def key = "<your key>"
def api = new YTranslateApiImpl(key)

Using instance of this service you can work with the following features:

  • DetectionApi detects the language of the specified text.
  • LanguageApi returns a list of translation directions supported by the service.
  • TranslationApi allows to translate text from one language to another.

DetectionApi

The following example returns Language.EN:

def language = api.detectionApi().detect("Hello, World!")

LanguageApi

To retrieve all available languages without their names, use the following code snippet:

def languages = api.languageApi().all()

It is also possible to fetch names for each language, using ui parameter:

def languages = api.languageApi().all(Language.RU)

TranslationApi

The following code should translate Russian's "Как дела?" to some English variant ("How are you doing?" or something similar):

def translation = api.translationApi().translate(
    "Как дела?", Direction.of(Language.RU, Language.EN)
)

Source language could be also detected automatically (so you need to specify only target language):

def translation = api.translationApi().translate("Как дела?", Language.EN)

Thanks to

License

MIT

yandex-translate-api's People

Contributors

emirkilic avatar vbauer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

yandex-translate-api's Issues

Removal of Attribution if Purchasing License?

Hi - tried to submit request through your website but have not received a response. Re: the attribution clause in the license, is this waived if one is to purchase translations? Thanks in advance.

NoClassDefFoundError error occurs

Steps to reproduce:

  • Create empty Maven project with the following pom.xml:


4.0.0

<groupId>com.acme</groupId>
<artifactId>yandex-translate</artifactId>
<version>1.0-SNAPSHOT</version>

<dependencies>
    <dependency>
        <groupId>com.github.vbauer</groupId>
        <artifactId>yandex-translate-api</artifactId>
        <version>1.2.2</version>
    </dependency>
</dependencies>

<repositories>
    <repository>
        <id>jitpack.io</id>
        <url>https://jitpack.io</url>
    </repository>
</repositories>
  • Execute the following peace of code:

     api.detectionApi().detect("Hello, World!");
    
  • The following error occurs:

Exception in thread "main" java.lang.NoClassDefFoundError: com/google/gson/GsonBuilder
at com.github.vbauer.yta.service.transport.impl.DataConverterImpl.createConverter(DataConverterImpl.java:59)
at com.github.vbauer.yta.service.transport.impl.DataConverterImpl.(DataConverterImpl.java:44)
at com.github.vbauer.yta.service.basic.ApiContext.of(ApiContext.java:80)
at com.github.vbauer.yta.service.YTranslateApiImpl.(YTranslateApiImpl.java:58)

Detected Languages Missing Name Optional

I am having trouble getting the name Optional from this: Language in = api.detectionApi().detect(translate).get(); Which gives me an error saying it is empty when I try: in.name().get(). Using a standard Language: Language convert = Language.EN; Works fine when I do this: convert.name().get() Not sure whether this is me or you, but maybe you can see something I don't even if it's my fault. Thanks for the help!

having issues getting it to work with android studio

Getting many calls to add translation to my app and since its generating a ton of text from many many generators i have created, translating them all would mean that ...well i do not have that may years left in me lol google api charges (my app is free so that is a big no no there) i came across yandex and your api but i have never used an api before so not sure if i am doing it right but i only get as far as the setup gradle part
i load up android studio, open my project go to the build.gradle (the first one as there is two)
add
url "https://jitpack.io" to the repository list result = http://pastebin.com/veBtDLNj

now android studio tells me that the gradle files have changed and the project needs to be synced, when i do that i get this error:

Error:(6, 0) Could not find method url() for arguments [https://jitpack.io] on repository container.
Open File

is there a special way to use this in an android project? (i did find it strange i did not need to download anything, was i meant to ? )
any tips would be gratefully recieved

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.