在 Debian 和 Ubantu 上安裝

硬件要求

Weblate 應該可以在任何現代硬件上正常運行,以下是在單個主機( Weblate,數據庫和 Web 服務器)上運行 Weblate 所需的最低配置:

  • 2 GB 的內存

  • 2 CPU cores

  • 1 GB 的存儲空間

內存越多越好 —— 用於所有級別的緩存(文件系統,數據庫和 Weblate )。

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

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

備註

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

安裝

系統要求

安裝所需的依賴包,來建立 Python 模塊(參見 軟件要求):

apt install -y \
   libxml2-dev libxslt-dev libfreetype6-dev libjpeg-dev libz-dev libyaml-dev \
   libffi-dev libcairo-dev gir1.2-pango-1.0 libgirepository1.0-dev \
   libacl1-dev libssl-dev libpq-dev libjpeg62-turbo-dev build-essential \
   python3-gdbm python3-dev python3-pip python3-virtualenv virtualenv git

根據您想要使用的特性來安裝想要的可選依賴包(參見 可選依賴性 ):

apt install -y \
   tesseract-ocr libtesseract-dev libleptonica-dev \
   libldap2-dev libldap-common libsasl2-dev \
   libxmlsec1-dev

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

本地安裝的使用說明:

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

# Web server option 2: Apache with ``mod_wsgi``
apt install -y apache2 libapache2-mod-wsgi-py3

# Caching backend: Redis
apt install -y redis-server

# Database server: PostgreSQL
apt install -y postgresql postgresql-contrib

# SMTP server
apt install -y exim4

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 可選依賴性 for fine-tuning of optional dependencies.

    備註

    On some Linux distributions running Weblate fails with libffi error:

    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
    
  4. Create an account for the administrator user and copy its password to the clipboard, and also save it for later use:

    weblate createadmin
    
  5. Collect the static files for your web server (see 運行服務器 and Serving static files):

    weblate collectstatic
    
  6. Compress the JavaScript and CSS files (optional, see Compressing client assets):

    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, 安卓字符串資源, 蘋果 iOS 字符串, Java 屬性, Stringsdict format or Fluent format, see 支持的文件格式 for more details.

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