Weblate

Install and configuration of Weblate

Docker install

Following steps in:

https://docs.weblate.org/en/latest/admin/deployments.html#docker

Steps done:

```sudo adduser weblate --home /var/www/weblate.co.tools sudo su weblate sudo mkdir /var/www/weblate.co.tools cd /var/www/weblate.co.tools git clone https://github.com/WeblateOrg/docker-compose.git weblate-docker cd weblate-docker

echo "version: '2' services: weblate: environment:

  - WEBLATE_EMAIL_HOST=smtp.co.tools
  - WEBLATE_EMAIL_HOST_USER=wave
  - WEBLATE_EMAIL_HOST_PASSWORD=pass
  - WEBLATE_SERVER_EMAIL=wave@communecter.org
  - WEBLATE_DEFAULT_FROM_EMAIL=wave@communecter.org
  - WEBLATE_ALLOWED_HOSTS=weblate.co.tools,localhost
  - WEBLATE_SITE_TITLE=Plateforme de traduction de Communecter
  - WEBLATE_ADMIN_PASSWORD=pass
  - WEBLATE_ADMIN_EMAIL=wave@communecter.org
  - WEBLATE_ADMIN_NAME="Administrateur"
  - WEBLATE_IP_PROXY_HEADER=HTTP_X_FORWARDED_FOR
  - WEBLATE_REGISTRATION_OPEN=1
  - WEBLATE_ENABLE_HTTPS=1
  - WEBLATE_SOCIAL_AUTH_GITLAB_KEY=application id
  - WEBLATE_SOCIAL_AUTH_GITLAB_SECRET=secret
  - WEBLATE_SOCIAL_AUTH_GITLAB_API_URL=https://weblate.co.tools/accounts/complete/gitlab/

" > docker-compose.override.yml


With values according to mail server.

And finally:

```sudo docker-compose up

Configure apache : /etc/apache2/sites-enabled/weblate.co.tools.conf :

<VirtualHost *:80>
        ServerName weblate.co.tools
        ServerAdmin webmaster@make.social

        ProxyPass / http://localhost:10080/
        ProxyPassReverse / http://localhost:10080/
        ProxyRequests Off
        ProxyPreserveHost On

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
</VirtualHost>

Configure lets encrypt :

certbot --apache -d weblate.co.tools

Et on repasse sur les fichiers de conf Apache weblate.co.tools-le-ssl.conf :

<IfModule mod_ssl.c>
<VirtualHost *:443>
        ServerName weblate.co.tools
        ServerAdmin webmaster@make.social

        ProxyPass / http://localhost:10080/
        ProxyPassReverse / http://localhost:10080/
        ProxyRequests Off
        ProxyPreserveHost On

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        RequestHeader set X-Forwarded-Proto "https"


SSLCertificateFile /etc/letsencrypt/live/weblate.co.tools/fullchain.pem
SSLCertificateKeyFile /etc/letsencrypt/live/weblate.co.tools/privkey.pem
Include /etc/letsencrypt/options-ssl-apache.conf
</VirtualHost>
</IfModule>

Ainsi que : weblate.co.tools.conf

<VirtualHost *:80>
        ServerName weblate.co.tools
        ServerAdmin webmaster@make.social

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined
        Redirect permanent / https://weblate.co.tools/
</VirtualHost>

Weblate configuration (pixel-humain project)

In weblate, a project is made of components. Each component has one translation file per language. If your source code uses many files for a given language, you will have to create a new component for each file.

Hopefully, weblate has a Component discovery addon. Using this addon, Weblate automatically discovers sources files for a given language. To use this addon, you have to :

  • Add a first component to your project. This component should translate a file that will not move in the future (for example, I chose the common.php file for pixel-humain project).
  • Then, enable the component discovery addon to automatically generate components. The translations of these components will be committed in the repo of the first component you created (common.php in my example). To push to Weblate repository, use the Repository management menu of the main component.

Gitlab configuration (co2-bot)

In weblate, when creating a new project, you have to create a first component to set the repository of the source code. You have to use two URLs : the source code repository, and the push repository. Select the main repository as the Source code Repository, and the fork repository as the Push URL.

On Gitlab :

  1. the weblate user is co2-bot. To use Weblate properly on Gitlab, you should fork the repo you want to integrate to Weblate using co2-bot user. For example co2-bot forked pixel-humain.
  2. set a webhook in the main repository to the weblate URL : https://weblate.co.tools/hooks/gitlab/

The workflow should be like below :

  1. As Developers, you will have to initialize empty translation files (with keys but no values). When you push to the source code repository, weblate will automatically pull the new files and update the translations accordingly.
  2. As Translators, you work on the translations. When you are ready, you can push to the push repository using Weblate interface.
  3. As Developers or Translators, when you have a major release, you should create a Merge Request between co2-bot fork repository and the main repository. Check the consistency of the files and do a squashed merge once you are ready.