升級 Weblate#

Docker 映像升級#

官方 Docker 映像(參見 使用 Docker 安裝 )整合了所有 Weblate 升級步驟。除了拉取最新版本外,通常不需要手動步驟。

通用的升級說明#

在升級前,請檢查目前的 軟體要求,因為他們可能被更改。一旦所有的要求被安裝或升級,請調整您的 settings.py,來匹配組態中的更改(正確的值請諮詢 settings_example.py)。

在升級前總是查看 版本特定說明。在您跳過一些版本的情況下,請遵從在升級中您跳過的所有版本的指示。有時最好升級到一些中間版本,來確保平滑遷移。跨多發行版本的升級應該可以工作,但還沒有像單一版本升級一樣測試過。

備註

推薦在升級前執行全資料庫備份,使您可以在升級失敗的情況下回滾資料庫,請參見 備份和移動 Weblate

  1. 停止 WSGI 和 Celery 進程。升級可能執行資料庫的不相容更改,因此在升級中避免舊的進程執行總是安全的。

  2. 升級 Weblate 代碼。

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

    pip install -U "Weblate[all]==version"
    

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

    pip install -U "Weblate[all]"
    

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

    pip install -U Weblate
    

    通過 Git 核實,您需要取回新的來源碼並升級您的安裝:

    cd weblate-src
    git pull
    # Update Weblate inside your virtualenv
    . ~/weblate-env/bin/pip install -e '.[all]'
    # Install dependencies directly when not using virtualenv
    pip install --upgrade -e .
    # Install optional dependencies directly when not using virtualenv
    pip install --upgrade -e '.[all]'
    
  3. New Weblate release might have new Python 相依性, please check if they cover features you want.

  4. 升級組態文件,所需的步驟請參考 settings_example.py版本特定說明

  5. Upgrade database structure:

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

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

    weblate compress
    
  8. 如果您執行來自 Git 的版本,每次升級時還應該重新產生 locale 文件。可以通過呼叫後面的來進行:

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

    weblate check --deploy
    
  10. Restart Celery worker (see 使用 Celery 的後台任務).

版本特定說明#

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

Upgrade from an older major version#

Upgrades across major versions are not supported. Always upgrade to the latest patch level for the initial major release. 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.

從其它資料庫遷移到 PostgreSQL#

If you are running Weblate on other dabatase than PostgreSQL, you should consider migrating to PostgreSQL as Weblate performs best with it. The following steps will guide you in migrating your data between the databases. Please remember to stop both web and Celery servers prior to the migration, otherwise you might end up with inconsistent data.

建立 PostgreSQL資料庫#

在另一個單獨的資料庫中執行 Weblate,並將使用者帳戶分開通常是個好方法:

# 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#

pgloader 是通用遷移工具,將資料遷移到 PostgreSQL。您可以使用它來遷移 Weblate 資料庫。

  1. 調整 settings.py 文件而將 PostgreSQL 用作資料庫。

  2. 遷移 PostgreSQL 中的模式:

    weblate migrate
    weblate sqlflush | weblate dbshell
    
  3. 執行 pgloader 來轉移資料。後面的腳本可以用於遷移資料庫,但您會想要學習更多關於 pgloader 的知識,來理解它做什麼以及調整它來匹配您的設定:

    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'
    ;
    

Migrating from Pootle#

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