With the WritePath Translation API and Proofreading API, developers can easily access a large number of experienced translators & editors with industry expertise in more than 35 languages. This API offers an easy and efficient way to integrate translation into your backend system, user interface, document management system, web shop, website content management system (CMS), mobile app, etc. It helps to automate repeating processes, cuts down process costs and gives you more time to focus on your core business.
For details check the Java translation API documentation. It takes care of authorization, JSON encoding and decoding and it can do a few more very convenient things.
Sign up at writepath.co and request your API keys.public class Client
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.lang.String |
apiKey
Your API key
|
private com.fasterxml.jackson.databind.ObjectMapper |
objectMapper |
private java.lang.String |
privateKey
Your private API key
|
private java.lang.String |
url
Address of API
|
Constructor and Description |
---|
Client(java.lang.String apiKey,
java.lang.String privateKey)
Instantiate new Client with your public and private API key set
|
Modifier and Type | Method and Description |
---|---|
private java.lang.String |
encodeFileToBase64Binary(java.lang.String fileName) |
Reply |
getLanguages(int service)
Fetch the list of supported languages
|
Reply |
getStatus(int jobId,
int format)
Retrieves a specific job.
|
Reply |
getWordBalance()
Fetch the word balance for the user
|
Reply |
getWordCountDocument(int service,
int langId,
java.lang.String fileName)
Fetch the word count for .docx, .xlsx or .pptx documents
|
Reply |
getWordCountPlainText(int service,
int langId,
java.lang.String text)
Fetch the word document for plain text
|
private static java.lang.String |
hmacSha1(java.lang.String value,
java.lang.String key) |
Reply |
postComment(int jobId,
java.lang.String comment)
Post a comment on a job
|
private org.apache.http.client.methods.HttpPost |
preparePost(java.lang.String url,
Data data) |
Reply |
sendDocument(int service,
int langId,
int category,
java.lang.String fileName,
java.lang.String instructions,
java.lang.String notifyUrl)
Send a job with file attachment to the service
|
Reply |
sendPlainText(int service,
int langId,
int category,
java.lang.String text,
java.lang.String instructions,
java.lang.String notifyUrl)
Send a job with plain text to the service.
|
BatchReply |
sendBatchedPlainText(int service,
int langId,
int category,
List <java.lang.String> text,
java.lang.String instructions,
java.lang.String notifyUrl)
Send batched jobs with plain text to the service.
|
BatchReply |
getBatchedStatus(int jobId,
int format)
Retrieves specific batched jobs.
|
private org.apache.http.client.methods.HttpPost preparePost(java.lang.String url, Data data) throws java.io.UnsupportedEncodingException, com.fasterxml.jackson.core.JsonProcessingException
- Throws:
java.io.UnsupportedEncodingException
com.fasterxml.jackson.core.JsonProcessingException
public Reply sendPlainText(int service, int langId, int category, java.lang.String text, java.lang.String instructions, java.lang.String notifyUrl) throws java.io.IOException
- Parameters:
service
- The service you require: 1 = editing, 2 = translation only, 4 = premium translation (translation + editing)langId
- The id of the translation / editing language.category
- The category / topic your text is about.text
- the text you would like to have translated or edited. Can include HTML tags, these are not counted as words.instructions
- instructions for the translator / editor.notifyUrl
- When job is finished, a REST post is sent to that URL- Returns:
- server reply with wordsUsed and orderId set
- Throws:
java.io.IOException
- in case of network or json mapping issues
public Reply sendDocument(int service, int langId, int category, java.lang.String fileName, java.lang.String instructions, java.lang.String notifyUrl) throws java.io.IOException
- Parameters:
service
- The service you require: 1 = editing, 2 = translation only, 4 = premium translation (translation + editing)langId
- The id of the translation / editing language.category
- The category / topic your text is about.fileName
- The path + filename of your document (only .docx, .pptx, .xlsx)instructions
- instructions for the translator / editor.notifyUrl
- When job is finished, a REST post is sent to that URL- Returns:
- server reply with wordsUsed and orderId set
- Throws:
java.io.IOException
- in case of network or json mapping issues
public Reply getStatus(int jobId, int format) throws java.io.IOException
- Parameters:
jobId
- id of the job you want to fetch. It's the orderId you get returned if you post a job.format
- The format of the returned content. 1 = as a file, 2 = as plain text- Returns:
- server reply with wordsUsed, status, dueDate, wordsBalance, commentFinished and document set
- Throws:
java.io.IOException
- in case of network or json mapping issues
public Reply postComment(int jobId, java.lang.String comment) throws java.io.IOException
- Parameters:
jobId
- The id of the job (= orderId) you want to comment on.comment
- Your comment- Returns:
- server reply with empty response
- Throws:
java.io.IOException
- in case of network or json mapping issues
public Reply getLanguages(int service) throws java.io.IOException
- Parameters:
service
- id of service needed- Returns:
- server reply with langArray set
- Throws:
java.io.IOException
- in case of network or json mapping issues
public Reply getWordBalance() throws java.io.IOException
- Returns:
- server reply with words balance set
- Throws:
java.io.IOException
- in case of network or json mapping issues
public Reply getWordCountPlainText(int service, int langId, java.lang.String text) throws java.io.IOException
- Parameters:
service
- The service you require: 1 = editing, 2 = translation only, 4 = premium translation (translation + editing)langId
- The id of the translation / editing language.text
- the text you would like to have translated or edited. Can include HTML tags, these are not counted as words.- Returns:
- server reply with word count set
- Throws:
java.io.IOException
- in case of network or json mapping issues
public Reply getWordCountDocument(int service, int langId, java.lang.String fileName) throws java.io.IOException
- Parameters:
service
- The service you require: 1 = editing, 2 = translation only, 4 = premium translation (translation + editing)langId
- The id of the translation / editing language.fileName
- path of file that needs to be checked- Returns:
- server reply with word count set
- Throws:
java.io.IOException
- in case of network or json mapping issues