在 Redhat 、 Fedora 和 CentOS 上安裝#

硬體要求#

Weblate 應該可以在任何現代硬體上正常執行,以下是在單個主機( Weblate,資料庫和 Web 伺服器)上執行 Weblate 所需的最低組態:

  • 3 GB of RAM

  • 2 CPU 核心

  • 1 GB 的儲存空間

記憶體越多越好 —— 用於所有級別的快取(檔案系統、資料庫和 Weblate )。

許多並髮使用者會增加所需的 CPU 內核數量。對於數百個翻譯組件,推薦至少有 4 GB 的內存。

典型的資料庫儲存用量大約為每一百萬單詞 300 MB。克隆倉儲所需的儲存空間會變化,但 Weblate 試圖通過淺克隆將其大小最小化。

備註

根據 Weblate 中管理的翻譯大小,安裝 Weblate 的實際要求差異很大。

提示

For systems with less memory than recommended, Single-process Celery setup is recommended.

安裝#

系統要求#

安裝所需的相依項,來建立 Python 模組(請參見 軟體要求):

dnf install \
   libxslt-devel libxml2-devel freetype-devel libjpeg-devel zlib-devel \
   libyaml-devel libffi-devel cairo-devel cairo-gobject-devel pango-devel \
   gobject-introspection-devel libacl-devel python3-pip python3-virtualenv \
   libtool-ltdl-devel python3-devel git

Install wanted optional dependencies depending on features you intend to use (see Python 相依性):

dnf install openldap-devel libsasl2-devel
dnf install xmlsec1-devel

可選地安裝生產伺服器執行所需要的軟件,參見 正在執行伺服器Weblate 的資料庫設定使用 Celery 的後台任務。根據於您的安裝所佔的空間,您會想要在特定的伺服器上運行這些組件。

本地安裝的使用說明:

# Web server option 1: NGINX and uWSGI
dnf install nginx uwsgi uwsgi-plugin-python3

# Web server option 2: Apache with ``mod_wsgi``
dnf install apache2 apache2-mod_wsgi

# Caching backend: Redis
dnf install redis

# Database server: PostgreSQL
dnf install postgresql postgresql-contrib

# SMTP server
dnf install postfix

# Gettext for the msgmerge add-on
dnf install gettext

Python 模組#

提示

我們使用 virtualenv 在與您的系統隔開的環境安裝 Weblate。如果您不熟悉,查看 virtualenv User Guide

  1. 為 Weblate 新建 virtualenv:

    virtualenv ~/weblate-env
    
  2. 為 Weblate 啟動 virtualevn :

    . ~/weblate-env/bin/activate
    
  3. Install Weblate including all optional dependencies:

    # Install Weblate with all optional dependencies
    pip install "Weblate[all]"
    

    Please check Python 相依性 for fine-tuning of optional dependencies.

    備註

    在一些 Linux 發行版執行 Weblate 發生 libffi 相關錯誤:

    ffi_prep_closure(): bad user_data (it seems that the version of the libffi library seen at runtime is different from the 'ffi.h' file seen at compile-time)
    

    This is caused by incompatibility of binary packages distributed via PyPI with the distribution. To address this, you need to rebuild the package on your system:

    pip install --force-reinstall --no-binary :all: cffi
    

組態 Weblate#

備註

The following assumes the virtualenv used by Weblate is activated (by executing . ~/weblate-env/bin/activate). If not, specify the full path to the weblate command as ~/weblate-env/bin/weblate.

  1. 將文件:file:~/weblate-env/lib/python3.9/site-packages/weblate/settings_example.py 複製為:file:~/weblate-env/lib/python3.9/site-packages/ weblate/settings.py

  2. Adjust the values in the new settings.py file to your liking. You will need to provide at least the database credentials and Django secret key, but you will want more changes for production setup, see 調整組態.

  3. Create the database and its structure for Weblate (the example settings use PostgreSQL, check Weblate 的資料庫設定 for a production-ready setup):

    weblate migrate
    

    也參考

    migrate

  4. Create an administrator user account admin, generate its password, and copy it to the clipboard; remember to save it for later use:

    weblate createadmin
    

    提示

    If you previously missed/lost the admin password, you can generate a new one with the following command:

    weblate createadmin --update
    

    也參考

    createadmin

  5. Collect the static files for your web server (see 正在執行伺服器 and 靜態檔案服務):

    weblate collectstatic
    
  6. Compress the JavaScript and CSS files (optional, see 壓縮客戶端素材):

    weblate compress
    
  7. Start the Celery workers. This is not necessary for development purposes, but strongly recommended otherwise. 使用 Celery 的後台任務 has more info:

    ~/weblate-env/lib/python3.9/site-packages/weblate/examples/celery start
    
  8. Start the development server (正在執行伺服器 details a production setup):

    weblate runserver
    

安裝後#

恭喜,您的 Weblate 服務現在已上線了,您可以開始使用它。

  • 您可以在 http://localhost:8000/ 存取 Weblate。

  • Sign in with admin credentials obtained during installation or register with new users.

  • 現在,您可以在 Weblate virtualenv 活動時使用 weblate 命令來執行 Weblate 命令。

  • 您可以使用 Ctrl+C 來停止測試的伺服器。

  • Review potential issues with your installation either on /manage/performance/ URL (see 效能報告) or using weblate check --deploy, see 生產設定.

新增翻譯#

  1. 打開管理界面( http://localhost:8000/create/project/ ),並新建您想要翻譯的項目。更多細節請參見 項目組態

    這裡所有需要您指定的只是項目名稱及其網站。

  2. 新建組件,它是翻譯的真實對象——它執行版本控制系統(VCS )倉儲,並用於選擇那個文件被翻譯。更多細節請參見 組件組態

    The important fields here are: 組件名稱, 來源碼儲存庫, and 檔案遮罩 for finding translatable files. Weblate supports a wide range of formats including GNU gettext PO (Portable Object), Android 字串資源, 蘋果 iOS 字串, Java 屬性, Stringsdict 格式 or 流暢的格式, see 支援的文件格式 for more details.

  3. 一旦完成上面的工作(根據您的版本控制系統 VCS 倉儲的大小,以及需要翻譯的資訊數量,這可能是個漫長的過程),您就可以開始翻譯了。