Skip to main content
Help us improve PyPI by participating in user testing. All experience levels needed!

The translations service server

Project description


Manage, store and deliver translations.


A translation starts out with a key, usually the English version of the text. For each key there can be a translation for another language. That is the second parameter for a translation.

A translation can also be country depended, the third parameter.

The last parameter specifies the plural version of the translation. This is needed for when the translation refers to some amount and needs to be different depending on what that amount is.

Rules for finding a translation

The parameters for getting a translation are:

  • key: the text to translate
  • lang: the language for the translation, following ISO 639-1
  • country [optional] the country for the translation, following ISO 3166-1 alpha-2
  • plural [optional] the related value that defines the plural form of the translation

The steps taken to find a translation are:

  • find all translations for the given key
  • only keep the ones with the specified language
  • from that list keep the ones with a matching country, if there are no entries with a matching country keep the ones without a specified country
  • if a plural parameter was specified try to find entries with that plural value otherwise select the translation where no plural value was specified
  • if more than one translations are left take the first one, if no translation is left take the key as the translation instead


  • Prepare a Postgres database and user.

  • Install npm.

  • Create and activate a Python 3 virtual environment.

  • Clone/download the project.

  • Then go to that project folder and run:

    $ npm install
    $ grunt migrate
    $ cd src
    $ cp
  • Review and edit this new file

Database URL example

Connecting to a database named test`on a local postgres server with user `postgres and no password: “postgres://postgres:@


After completing the installation and activating the Python environment go to the project folder and start a development server like this:

$ cd src
$ ./

How you run your server in production depends on your production environment.

Run ./ –help for port options.

Run tests

Prepare an empty test database and configure it in through TRANSLATIONS_SERVER_TEST_DB_URL in Then go to the project folder and run:

$ cd test
$ ./

Add and edit translations

Theres are each a table for languages and countries. If a new alnguage or country is needed those tables need to be updated first:

translations_server=# INSERT INTO languages (language_code, name)
VALUES ('en', 'English');
translations_server=# INSERT INTO countries (country_code, name)
VALUES ('US', 'United States of America');

There is no support for states, yet. Optionally one could modify the countrie codes to include the states information.

All translations then reside in the translations table, which contains:

  • translation_id
  • translation_key: The key (original text) for the translation.
  • language_id: References languages.
  • country_id: References countries.
  • plural: The plural count (variation) for which this translation is for.
  • translation_text: The translated text.

The table can be manipulated by either working on it directly or by using a admin interface such as Django admin (use Multiple databases).

ZMQ protocol

The server takes on request at the configured port number and responds with a replay to each request.

Each request shall send at least 4 frames containing:

  • language
  • country or `""`
  • key
  • plural or `""`

Each request may further contain more frames in pairs, each containing:

  • key
  • plural or `""`

For example:

"User not active"

An example requesting two translations:

"User not active"
"User not found"

The server shall then respond with either exactly one frame containing an empty string or as many frames as keys where send, each containing the translation for the corresponding key.

The response with only one frame containing an empty strings signals a server error.

Response example for requesting two keys:

"Användare ej aktiv"
"User not found"

Project details

Release history Release notifications

This version
History Node


History Node


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Filename, size & hash SHA256 hash help File type Python version Upload date
TranslationsServer-0.1.1-py3-none-any.whl (10.9 kB) Copy SHA256 hash SHA256 Wheel py3 Aug 1, 2016
TranslationsServer-0.1.1.tar.gz (7.9 kB) Copy SHA256 hash SHA256 Source None Aug 1, 2016

Supported by

Elastic Elastic Search Pingdom Pingdom Monitoring Google Google BigQuery Sentry Sentry Error logging CloudAMQP CloudAMQP RabbitMQ AWS AWS Cloud computing Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page