Content translation/cxserver/Setup

Note: Using Docker will make this setup easier. Please refer Content Translation Docker configuration documentation if you like to use it


Get the code[edit]

Content Translation Server[edit]

If you want to do an anonymous checkout:

git clone

Or if you plan to hack CXServer, then please follow the Gerrit 'getting started' docs and use an authenticated checkout url instead, such as:

git clone ssh://<user>


Install nodejs 8 or higher. When you are using Ubuntu and depending on OS version you may not end up with the most recent version of nodejs please read this [1] first before you proceed:

sudo apt-get install nodejs npm
nodejs --version # should now print 8 or higher

For other systems, see:

JS dependencies[edit]

Install the JS dependencies. Run this command in the cxserver directory:

npm install

Dictd Server[edit]


sudo apt-get install dictd

To install language pair,

sudo apt-get install dict-freedict-xxx-yyy

Where xxx and yyy are two different languages.

On CentOS 7 instead do:

rpm -Uvh dictd-server-1.12.0-6.4.x86_64.rpm

RESTBase Server[edit]


See RESTBase/Installation.

Server Configuration[edit]

An example configuration file is given as and

RESTBase configuration section[edit]

        method: '{{request.method}}'
        uri: http://localhost:7231/YOUR_WIKI_WEBSITE/v1/{+path}
        query: '{{ default(request.query, {}) }}'
        headers: '{{request.headers}}'
        body: '{{request.body}}'

Apertium configuration section[edit]

          api: http://localhost:2737

The server expected on localhost:2737 is then Apertium-apy . (See for instructions; you'll have to install Apertium and at least one language pair too). Adjust configuration according to your requirement and restart the server.

Run the server[edit]

Using node[edit]

$ nodejs server.js

On CentOS 7:

$ node server.js

Using npm[edit]

$ npm start

As a cxserver command[edit]

Following step is to be performed only once. You might have to use 'sudo'.

$ npm link .

Subsequently, just use following to start the server.

$ cxserver

Then browse to http://localhost:8080/v1 You'll see the server playground page.

Running it in secure mode (https)[edit]

In the configuration file, provide the SSL certificate details and set value of 'secure' as true


To run the ContentTranslation server:

$ npm run-script debug

It will open Chrome developer tools with the ContentTranslation source code. You can debug the code just like a web application. You can also edit the code and save from the debugger.

Starting cxserver automatically[edit]

There are many ways to start services automatically, consult your server's operating system documentation.


On Ubuntu and other operating systems using Upstart, one approach is

sudo ln -s /lib/init/upstart-job /etc/init.d/cxserver
sudo vi /etc/init/cxserver.conf

And, use following upstart script template:

# Upstart job configuration for cxserver

description "cxserver service"

start on (local-filesystems and net-device-up IFACE!=lo)
stop on runlevel [!2345]

setuid "www-data"
setgid "www-data"

env NODE_PATH="/path/to/cxserver/node_modules"

chdir "/path/to/cxserver"
exec npm start


To start cxserver,

sudo service cxserver start

To stop cxserver,

sudo service cxserver stop


Upstart can be debug using log messages at /var/log/syslog.


On recent versions of Debian, Fedora and other operating systems using systemd, use a cxserver.service unit file similar to the following template (modify the file paths as appropriate) and place file at /lib/systemd/system/ directory.

Description=MediaWiki Content Translation service


ExecStart=/usr/bin/node /path/to/cxserver/server.js

To start cxserver,

sudo service cxserver start

To stop cxserver,

sudo service cxserver stop

If you change in service script, you need to reload script by,

sudo systemctl --system daemon-reload


Systemd scripts logs messages at /var/log/syslog. It can be customized using StandardOutput= in cxserver.service script.

Backend Services[edit]



sudo apt-get install varnish


1. Configure varnish http accelerator port:

edit /etc/default/varnish

Example configuration to run varnish on port 8000

DAEMON_OPTS="-a :8000 \
             -T localhost:6082 \
             -f /etc/varnish/default.vcl \
             -S /etc/varnish/secret \
             -s malloc,256m"

2. Configure the varnish default backend:

edit /etc/varnish/default.vcl

backend default {
    .host = "";
    .port = "8080";

3. Restart the varnish:

sudo service varnish restart

Make sure you are running cxserver nodejs server on port 8080 - the backend configuration of varnish

cxserver --port=8080 will be your server URL with varnish will be your server URL without varnish

4. Configure cxclient's wgContentTranslationServerURL to

Extensions dependencies[edit]

Content translation extension requires following extensions as dependencies.

  1. BetaFeatures
  2. Cite
  3. UniversalLanguageSelector
  4. VisualEditor
  5. GlobalPreferences

Also see[edit]