Installing Weblate

From Minetest Developer Wiki
Jump to: navigation, search


How to install Weblate 2.0 with Nginx and PostgreSQL on Ubuntu 14.04

This tutorial describes how the Weblate instance at is installed.

If you wish to install Weblate for a different project, please consult the official Weblate documentation.

All of the following commands are supposed to be run as root. Otherwise run them with sudo.


# Install requirements
apt-get install nginx uwsgi uwsgi-plugin-python git memcached fcgiwrap \
    postgresql libpq-dev python-pip python-virtualenv \
    python-dev libxml2-dev libxslt-dev libicu-dev

# If PostgreSQL was not installed before, set the master password
sudo -u postgres psql postgres -c "\password postgres"

# Create database user called "weblate"
sudo -u postgres createuser -D -A -P weblate

# Create database "weblate" owned by "weblate"
sudo -u postgres createdb -O weblate weblate

# Prepare directories that should be writable by weblate
for dir in /var/lib/weblate/{,avatar-cache,repos,whoosh-index}; do
	mkdir -p $dir && chown -R www-data:www-data $dir && chmod -R 700 $dir;

# Prepare /var/www
mkdir -p /var/www
chown root:www-data /var/www
chmod 750 /var/www

# Download and extract weblate
cd /var/www
sha512sum weblate-2.0.tar.xz 
# ^ should print 37898e57a5eacc45fd0a5dca52faea235bd3102dcc6a6fb5455d4edfdabdab4f4c306674f3b71dd9749584645c914b2afa5f2f52e224238088795ba8720b9b47  weblate-2.0.tar.xz
tar -xvf weblate-2.0.tar.xz --no-same-owner
ln -s weblate-2.0 weblate

# Install weblate dependencies into a virtual environment at /var/www/weblate/env
virtualenv /var/www/weblate/env
source /var/www/weblate/env/bin/activate
pip install -r /var/www/weblate/requirements-optional.txt \
            psycopg2 python-memcached pydns

Configure weblate

cd /var/www/weblate
cp weblate/ weblate/
# Generate a secret key, used for SECRET_KEY in weblate/
# (Copy output to clipboard)
vim weblate/

Add/change the following settings. Leave everything else at the defaults.

DEBUG = False

    # people that will receive error notifications, e.g.:
    ('noreply', ''),

    'default': {
        # Use 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
        'ENGINE': 'django.db.backends.postgresql_psycopg2',
        # Database name or path to database file if using sqlite3.
        'NAME': 'weblate',
        # Database user, not used with sqlite3.
        'USER': 'weblate',
        # Database password, not used with sqlite3.
        ##### CHANGE THIS! #####
        'PASSWORD': '????',
        # Set to empty string for localhost. Not used with sqlite3.
        'HOST': '',
        # Set to empty string for default. Not used with sqlite3.
        'PORT': '',


SECRET_KEY = '...'   # as generated by examples/generate-secret-key

    ('django.template.loaders.cached.Loader', (

    # 'social.backends.suse.OpenSUSEOpenId',

GIT_ROOT = '/var/lib/weblate/repos'

SITE_TITLE = 'Minetest Weblate'

OFFLOAD_INDEXING = True   # we have to run update_index as cronjob

WHOOSH_INDEX = '/var/lib/weblate/whoosh-index'




    'default': {
        'BACKEND': 'django.core.cache.backends.memcached.MemcachedCache',
        'LOCATION': '',
    'avatar': {
        'BACKEND': 'django.core.cache.backends.filebased.FileBasedCache',
        'LOCATION': '/var/lib/weblate/avatar-cache',
        'TIMEOUT': 604800,
        'OPTIONS': {
            'MAX_ENTRIES': 1000,

os.environ['HOME'] = '/var/lib/weblate'

# Change as needed, see django documentation

Save and exit.

Configure nginx

vim /etc/nginx/sites-available/weblate
server {
	listen 80;
	listen [::]:80 default ipv6only=on;
	root /var/www/weblate/weblate;

	location /favicon.ico {
		alias /var/www/weblate/weblate/media/favicon.ico;
		expires 30d;

	location /media/ {
		alias /var/www/weblate/weblate/media/;
		expires 30d;

	location /robots.txt {
		alias /var/www/weblate/weblate/media/robots.txt;
		expires 30d;

	location /static/admin/ {
		alias /var/www/weblate/env/lib/python2.7/site-packages/django/contrib/admin/static/admin/;
		expires 30d;

	location ~ /git(/.*) {
		# export minetest repo as

		gzip off;
		root /usr/lib/git-core;
		fastcgi_param SCRIPT_FILENAME     /usr/lib/git-core/git-http-backend;
		fastcgi_param DOCUMENT_ROOT       /usr/lib/git-core;
		fastcgi_param SCRIPT_NAME	  git-http-backend;
		fastcgi_param GIT_HTTP_EXPORT_ALL "";
		fastcgi_param GIT_PROJECT_ROOT    /var/lib/weblate/repos/minetest;
		fastcgi_param PATH_INFO           $1;
		include       /etc/nginx/fastcgi_params;
		fastcgi_pass  unix:/var/run/fcgiwrap.socket;

	location / {
		include uwsgi_params;
		# Needed for long running operations in admin interface
		uwsgi_read_timeout 3600;

Save and exit, then:

ln -s /etc/nginx/sites-{available,enabled}/weblate
rm /etc/nginx/sites-enabled/default  # if this is the first time nginx is installed

Configure uwsgi

vim /etc/uwsgi/apps-available/weblate.ini
plugins       = python
master        = true
protocol      = uwsgi
socket        =
wsgi-file     = /var/www/weblate/weblate/
virtualenv    = /var/www/weblate/env
python-path   = /var/www/weblate
# Needed if you want to use SSH keys
unenv         = HOME
# Needed for OAuth/OpenID
buffer-size   = 8192
# Increase number of workers for heavily loaded sites
#workers       = 6
# Needed for background processing
enable-threads = true

Save and exit, then:

ln -s /etc/uwsgi/apps-{available,enabled}/weblate.ini

Create weblate database and superuser account

cd /var/www/weblate

# Create tables for weblate
./ syncdb
./ makemigrations
./ migrate

# Create a superuser
./ createsuperuser

Install indexing cronjob

  • crontab -e
*/5 * * * * /var/www/weblate/env/bin/python2.7 /var/www/weblate/ update_index

Restart nginx & uwsgi

  • Make sure firewall settings are correct (i.e. allow incoming TCP connections on port 80)
  • Restart services
service nginx restart
service uwsgi restart

Set up site configuration

  • Log in at with the superuser account
  • Click on Sites, then
  • Replace Domain name and Display name with, then save
  • Restart uwsgi again in order to clear the site cache:
service uwsgi restart

Check performance report

  • In admin interface: Click on Home, then Performance report.
  • All results should be green checkmarks.

Add project

  • Click on Home, then Projects -> Add
  • Project name: Minetest
  • URL slug: minetest
  • Project website:
  • Mailing list:
  • Translation instructions:
  • Push on commit: no
  • Set Translation-Team header: yes
  • Enable ACL: no
  • Enable hooks: yes


Add subproject

  • Note: saving the subproject will take a while (several minutes) because it clones the minetest repository.
  • Click on Home, then Sub projects -> Add
  • Component name: Minetest
  • URL slug: minetest
  • Project: Minetest
  • Source code repository:
  • Repository push URL:
  • Repository browser:
  • Exported repository URL:
  • Source string bug report address:
  • Repository branch: master
  • File mask: po/*/minetest.po
  • Monolingual base language file:
  • Base file for new translations:
  • File format: Gettext PO file
  • Additional commit file:
  • Pre-commit script:
  • Locked: no
  • Allow translation propagation: yes
  • Save translation history: yes
  • Enable suggestions: yes
  • Suggestion voting: no
  • Autoaccept suggestions: 0
  • Quality checks flags:
  • Translation license: LGPL-2.1
  • License URL:
  • New language: Use contact form
  • Merge style: Merge
  • Commit message: (keep default)
  • Committer name: Weblate
  • Committer email:

Save, logout & exit the admin interface.

GitHub integration part 1: OAuth

Log in to GitHub and click on Settings -> Applications -> Register new application, then enter the following data:

  • Application name: Minetest Weblate
  • Homepage URL:
  • Application description: Web-based translation tool for Minetest
  • Authorization callback URL:

Register the application, which will generate a Client ID and a Client Secret.

Edit /var/www/weblate/weblate/ again and define:

SOCIAL_AUTH_GITHUB_KEY = '...'     # Client ID
SOCIAL_AUTH_GITHUB_SECRET = '...'  # Client Secret

GitHub integration part 2: webhook

The purpose of the webhook is to let weblate automatically pull from the upstream repository whenever it changes.

Go to and click on Settings -> Webhooks & Services -> Add service -> Weblate. (A "service" is a webhook with application-specific defaults built in by GitHub)

In the form that comes up, enter as the URL and click on Add service. Done.

Personal tools