@Override
    public String translate(String text, String sourceLanguage, String targetLanguage)
            throws TikaException, IOException {
        if (!this.isAvailable) {
            return text;
        }
        Response response = client.accept(MediaType.APPLICATION_JSON).query("key", apiKey)
                .query("source", sourceLanguage).query("target", targetLanguage).query("q", text)
                .get();

        StringBuilder responseText = new StringBuilder();
        try (InputStreamReader inputStreamReader = new InputStreamReader(
                (InputStream) response.getEntity(), UTF_8);
                BufferedReader reader = new BufferedReader(inputStreamReader)) {
            String line;
            while ((line = reader.readLine()) != null) {
                responseText.append(line);
            }
        }

        ObjectMapper mapper = new ObjectMapper();
        JsonNode jsonResp = mapper.readTree(responseText.toString());
        return jsonResp.findValuesAsText("translatedText").get(0);
    }
An implementation of a REST client to the <a
href="https://www.googleapis.com/language/translate/v2">Google Translate v2
API</a>. Based on the <a
href="http://hayageek.com/google-translate-api-tutorial/">great tutorial</a>
from <a href="http://hayageek.com">hayageek.com</a>. Set your API key in
translator.google.properties.
tika-translate/src/main/java/org/apache/tika/language/translate/impl/GoogleTranslator.java