Skip to content

Translation service prototype that is backed by a hosted Elasticache (Redis) instance

License

Notifications You must be signed in to change notification settings

fastnsilver/xlator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

80 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

xlator

Build Status codecov.io Apache License 2

codecov.io

Translation service prototype that is backed by either an in-memory or a hosted Elasticache (Redis) instance

Current service implementation makes requests of frengly or Google Translate API.

to use Frengly

You will need to register for an account and add app.frengly.email and app.frengly.password to application.yml.

Note that frengly.com throttles requests, so intermittent HTTP 5xx responses are to be expected.

to use Google Translate

You will need to sign-up for a Google Cloud Platform account, then follow instructions to setup a project, billing, and enable Translate API calls. Then you'll need to configure application.yml by adding a app.google.key and changing app.defaults.service to be google.

Please review the disclaimer if you configure xlator to use Google Translate API.

The recommended way to update the application properties mentioned above is to create a config directory underneath src/main/resources and just add the key-value pairs mentioned above to it. This will serve as your application overrides. Consult the Application property files section of the Spring Boot documentation for further details.

Service Endpoints

GET /translation/source/{src}/target/{target}/text/{text}

GET /translation/target/{target}/text/{text}

  • Inputs: target locale and text to translate (default locale must be configured in application.yml)
  • Output: translation

GET /translation/source/{src}/targets/{targets}/text/{text}

  • Inputs: source locale, comma-separated target locales, and text to translate
  • Output: translations (one per target)

GET /translation/targets/{targets}/text/{text}

  • Inputs: comma-separated target locales and text to translate
  • Output: translations (one per target)

POST /translation/

  • Inputs: A TranslationRequest array, this form is preferred for multi-word text translations and/or when you want to perform translations on different combinations of source, target and text input parameters
  • Output: translations

DELETE /translation/source/{src}/target/{target}/text/{text}

  • Inputs: cache key comprised of source locale, target locale and text that was previously translated
  • Output: entry is removed from cache provider

Developer Notes

This is a Spring Boot application.

It is initialized with: Application.java

Prerequisites

  • Java JDK 1.8.0_181 or better
  • Maven 3.5.4 or better

How to build

$ mvn clean install

How to run

with Spring Boot

First, change directories

cd xlator

Then

$ mvn spring-boot:run

Or

$ java -jar xlator-x.x.x.jar

where x.x.x is a version like 0.0.1-SNAPSHOT

with Docker

Go get Docker for Windows, Mac, or Ubuntu

Build images
touch .dockerize
mvn clean install
Publish images

Consult the Authentication section of the docker-maven-plugin documentation for alternative options.

mvn docker:push -Ddocker.username={registry_username} -Ddocker.password={registry_password}

Replace {registry_username} and {registry_password } above with credentials to a registry like Docker hub. If you intend to use an alternate registry you'll expend a bit more effort to configure.

Pull images

Visit Dockerhub

Pull the xlator image

Run images

You will have to set some environment variables in startup.sh first!

cd deploy/docker
./startup.sh
Work with images

Services are accessible via the Docker host (or IP address) and port

Service Port
Xlator 80
Prometheus 9090
Grafana 3000
CAdvisor 9080
Redis 6379

Consider importing a couple of dashboards into Grafana, like jvm and throughput

Stop images (and remove them)
./shutdown.sh
docker-compose rm -f

Working with Maven Site

Note: as of 2018-08-05, this Maven Site is only known to generate successfully employing JDK 8u181.

Stage

mvn site site:stage -Pdocumentation

Publish

Assumes a gh-pages (orphan) branch has been set up in advance. In addition, appropriate authentication credentials have been declared in $HOME/.m2/settings.xml. See:

mvn scm-publish:publish-scm -Pdocumentation

I spent a couple hours troubleshooting failed attempts to publish my Maven Site. This Stack Overflow record got me over the hump. Even if you have multiple Github accounts managed in {user.home}/.ssh/config, you must still declare --global with user.name and user.email in order for the plugin to succeed.

Review

Roadmap

// TODO

  1. Improve test coverage

  2. Deploy service to AWS

Credits

Major props go out to

About

Translation service prototype that is backed by a hosted Elasticache (Redis) instance

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published