在 SUSE 和 openSUSE 上安裝

硬體要求

Weblate should run on any contemporary hardware without problems, the following is the minimal configuration required to run Weblate on a single host (Weblate, database and web server):

  • 3 GB of RAM

  • 2 CPU 核心

  • 1 GB 的儲存空間

備註

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

Memory usage

The more memory the better - it is used for caching on all levels (file system, database and Weblate). For hundreds of translation components, at least 4 GB of RAM is recommended.

提示

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

CPU usage

Many concurrent users increase the amount of needed CPU cores.

Storage usage

The typical database storage usage is around 300 MB per 1 million hosted words.

Storage space needed for cloned repositories varies, but Weblate tries to keep their size minimal by doing shallow clones.

Nodes

For small and medium-sized sites (millions of hosted words), all Weblate components (see Architecture overview) can be run on a single node.

When you grow to hundreds of millions of hosted words, it is recommended to have a dedicated node for database (see Weblate 的資料庫設定).

安裝

系統要求

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

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

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

zypper install libldap2-devel libsasl2-devel
zypper install libxmlsec1-devel

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

本地安裝的使用說明:

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

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

# Caching backend: Redis
zypper install redis-server

# Database server: PostgreSQL
zypper install postgresql postgresql-contrib

# SMTP server
zypper install postfix

# Gettext for the msgmerge add-on
zypper 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 倉儲的大小,以及需要翻譯的資訊數量,這可能是個漫長的過程),您就可以開始翻譯了。