Skip to content

A CKAN extension that provides APIs for translating strings using a third-party service.

License

Notifications You must be signed in to change notification settings

datopian/ckanext-translate

Repository files navigation

CKAN CKAN CKAN

Note: This plugin is tested with CKAN 2.8 or later version but hasn't been tested on earlier version.

ckanext-translate

This extension provides an REST API that translates the provided text into the given languages. At the moment, it uses IBM Watson Language Translator APIs on backend for translation. In the future, other third-part services can be integrated.

Installation

To install ckanext-translate extension.

  1. Activate your CKAN virtual environment, for example:

     . /usr/lib/ckan/default/bin/activate
    
  2. Clone the source and install it on the virtualenv

    git clone https://github.com/datopian/ckanext-translate.git
    cd ckanext-translate
    pip install -e .
    pip install -r requirements.txt
    
  3. Add translate to the ckan.plugins setting in your CKAN config file (by default the config file is located at /etc/ckan/default/ckan.ini) and restart ckan service.

Config settings

Following environment variables must be added. To get a IBM Watson Translator API key and url, you need to sign up for IBM cloud account and create Language translator instance.

  ckanext.translate.ibm_url = <IBM watson translator url>
  ckanext.translate.ibm_key = <IBM watson translator API key> 

API Documentation

API Endpont: /api/3/action/translate

input You can pass keys values text for the translate.
from Parameter to specify the language code of the language you want to translate from.
to Parameter to specify the language code of the language you want to translate.

Request example:

{
  "input": {
    "title": "My dataset title",
    "notes": "Some notes about my dataset."
  },
  "from": "en",
  "to": "fr"
}

Response example:

{
"result": {
  "output": {
      "title": "Mon titre de jeu de données",
      "notes": "Quelques notes sur mon jeu de données."
    }
  }  
}

Developer installation

To install ckanext-translate for development, activate your CKAN virtualenv and do:

git clone https://github.com/datopian/ckanext-translate.git
cd ckanext-translate
python setup.py develop

About

A CKAN extension that provides APIs for translating strings using a third-party service.

Topics

Resources

License

Stars

Watchers

Forks

Contributors 3

  •  
  •  
  •