This AAI Plugin implements an interface to the Google Translate API. It uses a caching mechanism for previously translated items and is the perfect tool to create multi-lingual Qlik Sense or QlikView applications
- Qlik Sense or QlikView November 2017 release (or later)
- Google API credentials
- Java version 1.8 (or later)
Because we use the Google Translate API we need to retrieve Google API credentials. Follow these steps:
- Login to the Google Cloud Platform Console
- In the Cloud Platform Console, go to the Manage resources page and select or create a new project.
- Enable billing for your project.
- Enable the Cloud Translation API for your project.
- After enabling the Google Cloud Translation API, click the Go to Credentials button to set up your Cloud Translation API credentials:
- See the Authentication guide for information on how to authenticate to the Cloud Translation API service from your code. Following those steps, you should obtain both a service account key file (in JSON) that will allow you to authenticate to the Translation API.
The plugin comes in a self contained zip-file with all the needed Java libraries. To get everything up and running follow these steps:
- Setup an environment variable to point to your Google JSON file like
GOOGLE_APPLICATION_CREDENTIALS=C:\google-credentials.json
- Download the latest release from here
- Unzip the zip-file in a dedicated directory
- Create a file called
Dictionary.properties
that has the following content:
ORIGIN_LANGUAGE=en
TRANSLATION_DIR=translations
- Create a directory called
translations
under the directory where you unzipped the release. - Start the server by calling
qs-google-translate\bin\google-translate-server.bat
(Windows)qs-google-translate\bin\google-translate-server
(Linux)
- The plugin is now listening on port 50054 for incoming connections
To make it easier to run the plugin there is a docker image available. For this you will need to have a running docker environment. Take the following steps to run it
- Create a directory called
config
- Copy the Google JSON credential file into
config/google.json
- Create a file called
config/Dictionary.properties
that has the following content:
ORIGIN_LANGUAGE=en
TRANSLATION_DIR=/translations
- Create a directory called
translations
- Start the docker image with the following command
docker run -d -p 50054:50054 \
-v $PWD/config:/config \
-v $PWD/translations:/translations \
wbvreeuwijk/qs-google-translate
For the plugin to be used in a Qlik Sense of QlikView application you will need to add the plugin hostname and port into the Settings.ini
file.
Modify this file to look like this
[Settings 7]
SystemLogVerbosity=5
SSEPlugin=J,localhost:50054
If you are running the plugin on a different server change localhost to point to this server.
Start or restart you Qlik Sense or Qlik View server or desktop application. If all is configured correctly you will see this in the log of the plugin.
In you Qlik Sense or QlikView application you can now use the following expressions:
J.TranslateLabel(<language>,<text>)
J.TranslateRows(<language>,<field>)
The language is the language to which the text needs to be translated. Check the supported language section to what parameter can be passed.
Look at the example application here ** The example application uses the qsVariable extension for the selection of languages **
When the plugin is called it will first look into the collection of known translations. These are stored in translation files in the translations directory based on the the from and to of the translations that are created. So en-ja.properties
will contain the translated texts from English to Japanese. If certain translations provided through the Google Translation API are not correct they can be changed by changing the translations properties file.
Please note that for performance reasons the translations are only read when the plugin is started
To understand what languages are support you can look at the Language Support page.
Use of the Google Translate API is not free, but charged by the number of characters. As of this writing Google charges $0.02 per 1000 characters per month. Learn more about pricing here: Google Cloud Platform Pricing Calculator
Currently Qlik Sense and QlikView do not support using AAI expressions as calculated dimensions.
Bas van Reeuwijk
Copyright (c) 2017 Bas van Reeuwijk
Released under the GPL-3.0.