升級 Weblate

Docker 映像升級

The official Weblate Docker image (see 使用 Docker 安裝) integrates all upgrade steps. Typically, no manual interaction is needed beyond pulling the latest (or at least newer) version.

通用升級指示

Always look for new changes to 軟體需求 before upgrading. Once all requirements are installed or upgraded, ensure your settings.py matches the changes in the configuration (consult settings_example.py for correct values).

在升級前務必查看 版本特定說明。在您略過一些版本的情況下,請務必遵從在升級中您所略過的所有版本的指示。有時最好升級到一些中間版本以確保順利遷移。跨多個發行版本的升級應該可行,但還沒有像單一版本升級一樣經過充分測試!

備註

Always back up the full database before upgrading, so that you can roll back the database if the upgrade fails, see 備份和移動 Weblate.

  1. Wait for the Celery queues to become empty, then stop the WSGI and Celery processes to avoid old processes running while upgrading. Otherwise incompatible changes in the database might occur.

    The Celery task queue is not a stable interface across releases, so queued tasks from the old version are not guaranteed to work after the upgrade. You can monitor queue length in the 管理介面 or by using celery_queues.

  2. 升級 Weblate

    對於 pip 安裝,可以通過後面的來實現:

    uv pip install -U "weblate[all]==version"
    

    或者,如果您只想取得最新發佈的版本:

    uv pip install -U "weblate[all]"
    

    If you don't want to install all of the optional dependencies do:

    uv pip install -U weblate
    

    Using Git checkout, you need to fetch new source code and update your installation:

    cd weblate-src
    git pull
    # Update Weblate inside your Python environment
    . ~/weblate-env/bin/uv pip install -e '.[all]'
    # Install dependencies directly when not using Python environment
    uv pip install --upgrade -e .
    # Install optional dependencies directly when not using a Python environment
    uv pip install --upgrade -e '.[all]'
    
  3. New Weblate releases might have new Python 依賴項, check if they cover the features you want.

  4. Upgrade the configuration file by following either settings_example.py, or 版本特定說明.

  5. 升級資料庫:

    weblate migrate --noinput
    
  6. 收集升級的靜態文件(請參閱 正在執行伺服器靜態檔案服務):

    weblate collectstatic --noinput --clear
    
  7. 壓縮 JavaScript 和 CSS 文件(可選步驟,請參閱 壓縮用戶端素材 ):

    weblate compress
    
  8. If you are running an installation from Git, you should also regenerate locale files every time you upgrade. You can do this by invoking:

    weblate compilemessages
    
  9. 驗證您的設定合理(還請參閱 生產設定):

    weblate check --deploy
    
  10. Restart the Celery worker (see 使用 Celery 的背景工作).

版本特定說明

在 5.0 版的變更: Version specific instructions are now included in the release notes, see Weblate 2026.6.

Upgrade from an older unsupported release

Direct upgrades are only supported for releases from the current or previous calendar year. If you need to upgrade across this boundary, upgrade first to an intermediate version as listed below. Upgrades skipping this step are not supported and will break.

  • If you are upgrading from the 2.x release, always first upgrade to 3.0.1.

  • If you are upgrading from the 3.x release, always first upgrade to 4.0.4.

  • If you are upgrading from the 4.x release, always first upgrade to 5.0.2.

  • If you are upgrading from 5.0.x-5.9.x, always first upgrade to 5.10.4.

  • Upgrades from 5.10.x and newer are currently directly supported.

從其它資料庫遷移到 PostgreSQL

警告

MySQL and MariaDB are no longer supported in Weblate. You must migrate to PostgreSQL before upgrading.

If you are running Weblate with MySQL or MariaDB, consider migrating to PostgreSQL for better performance by doing the following steps. Remember to stop both, the web and Celery servers beforehand, otherwise you might end up with inconsistent data.

建立 PostgreSQL資料庫

It is usually a good idea to run Weblate in a separate database, and a separate user account:

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

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

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

使用 pgloader 遷移到 PostgreSQL

The pgloader is a generic migration tool to migrate data to PostgreSQL. You can use it to migrate your Weblate database.

  1. Adjust your settings.py to use PostgreSQL as database.

  2. 遷移 PostgreSQL 中的模式:

    weblate migrate
    weblate sqlflush | weblate dbshell
    

3. Run the pgloader to transfer the data. The following script can be used to migrate the database, but you might want to learn more about pgloader to better understand what it does, and tweak it to match your setup:

LOAD DATABASE
     FROM mysql://weblate:password@localhost/weblate
     INTO postgresql://weblate:password@localhost/weblate

WITH include no drop, truncate, create no tables, create no indexes, no foreign keys, disable triggers, reset sequences, data only

ALTER SCHEMA 'weblate' RENAME TO 'public'
;

從 Pootle 遷移

As Weblate was originally written as a replacement for Pootle, it is supported to migrate the user accounts from it. You can dump the users from Pootle and import them using importusers.