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.
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.
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.
GET /translation/source/{src}/target/{target}/text/{text}
- Inputs: source locale, target locale and text to translate
- Output: translation
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
This is a Spring Boot application.
It is initialized with: Application.java
$ mvn clean install
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
Go get Docker for Windows, Mac, or Ubuntu
touch .dockerize
mvn clean install
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.
Visit Dockerhub
Pull the xlator image
You will have to set some environment variables in startup.sh first!
cd deploy/docker
./startup.sh
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
./shutdown.sh
docker-compose rm -f
Note: as of 2018-08-05, this Maven Site is only known to generate successfully employing JDK 8u181.
mvn site site:stage -Pdocumentation
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
withuser.name
anduser.email
in order for the plugin to succeed.
// TODO
-
Improve test coverage
-
Deploy service to AWS
Major props go out to