# 在 SUSE 和 openSUSE 上安裝

## 硬體需求

Weblate 應該可以在任何現代硬體上正常執行，以下是在單一主機（Weblate、資料庫和 Web 伺服器）上執行 Weblate 所需的最低設定：

* 3 GB 記憶體
* 2 個 CPU 核心
* 1 GB 儲存空間

#### NOTE
根據 Weblate 中管理的翻譯大小，安裝 Weblate 的實際需求差異很大。

### 記憶體使用

記憶體越多越好——用於所有層級的快取（檔案系統，資料庫和 Weblate）。如果有幾百個翻譯組件，那麼建議的最小記憶體為 4 GB。

#### HINT
對於記憶體低於建議值的系統，建議使用 [單行程 Celery 設定](https://docs.weblate.org/zh-tw/latest/admin/install.md#minimal-celery)。

### CPU 使用

大量並行使用者會提高需要的 CPU 核心數。

Weblate 2026.8 將 NumPy 列為必要相依套件。在 x86-64 系統上，Docker 映像檔所附的最佳化 NumPy 版本需要相容於 x86-64-v2 的 CPU。若 CPU 缺少必要功能，NumPy 就無法載入，Weblate 也無法啟動。

升級前，請在執行 Docker 的 Linux 系統上確認 CPU 是否具備必要的 SSE4.2 功能：

```sh
grep sse4_2 /proc/cpuinfo
```

沒有任何輸出，表示缺少某項必要的 CPU 功能。這只是初步檢查；檢查到 SSE4.2 並不能確認所有 x86-64-v2 CPU 功能都可用。

若 Docker 在虛擬機器中執行，請在虛擬機器內執行檢查。虛擬機器可能會隱藏主機支援的 CPU 功能。請設定虛擬機器，讓它能使用主機具備的必要 CPU 功能，然後重新啟動虛擬機器。若實體 CPU 不支援必要功能，請升級硬體。

### 儲存空間使用

典型的資料庫儲存用量為大約 300 MB/每 100 萬託管字詞。

複製儲存庫所需的儲存空間會因情況而異，但 Weblate 會透過淺層複製來盡量降低所需空間。

### 儲存效能

版本控制作業會執行大量檔案系統中繼資料查詢。因此，[`DATA_DIR`](https://docs.weblate.org/zh-tw/latest/admin/config.md#std-setting-DATA_DIR) 中的 `vcs` 子目錄需要低讀取延遲；即使儲存空間的大量資料傳輸效能良好，中繼資料存取緩慢仍可能使 **git status** 等作業耗費很長時間。請盡可能將 [`CACHE_DIR`](https://docs.weblate.org/zh-tw/latest/admin/config.md#std-setting-CACHE_DIR) 放在低延遲的本機或暫存儲存空間。

部署檢查會測量兩個位置的中繼資料查詢延遲，並在延遲中位數超過 10 毫秒時發出警告。這是會受到檔案系統及系統負載影響的時間點概略測量。變更儲存空間設定前，請重新執行 **weblate check --deploy**。

### 節點

對中小網站（幾百萬託管字詞），所有的 Weblate 組件（見 [架構概覽](https://docs.weblate.org/zh-tw/latest/admin/install.md#architecture)）可以執行在單一節點上。

當託管字詞數增長到數以億計時，建議使用專門的資料庫節點（見 [適用於 Weblate 的資料庫設定](https://docs.weblate.org/zh-tw/latest/admin/install.md#database-setup)）。

## 安裝

### 系統需求

安裝所需的相依套件以建立 Python 模組（請參閱 [軟體需求](https://docs.weblate.org/zh-tw/latest/admin/install.md#requirements)）：

```sh
zypper install \
   libxslt-devel libxml2-devel freetype-devel libjpeg-devel zlib-devel \
   libyaml-devel libffi-devel libacl-devel liblz4-devel libzstd-devel libxxhash-devel \
   python3-devel git
```

根據您想使用的功能來安裝想要的選用相依套件（請參閱 [Python 相依套件](https://docs.weblate.org/zh-tw/latest/admin/install.md#python-deps)）：

```sh
zypper install libldap2-devel libsasl2-devel
zypper install libxmlsec1-devel
```

選用地安裝生產伺服器執行所需要的軟體，參閱 [執行伺服器](https://docs.weblate.org/zh-tw/latest/admin/install.md#server) 、 [適用於 Weblate 的資料庫設定](https://docs.weblate.org/zh-tw/latest/admin/install.md#database-setup) 、 [使用 Celery 的背景工作](https://docs.weblate.org/zh-tw/latest/admin/install.md#celery)。根據於您的安裝所佔的空間，您會想要在特定的伺服器上執行這些組件。

本機安裝說明：

```sh
# 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: Valkey
zypper install valkey-server

# Database server: PostgreSQL
zypper install postgresql postgresql-contrib

# SMTP server
zypper install postfix

# Gettext tools for gettext POT/PO update add-ons
zypper install gettext
```

### uv 套件管理器

#### HINT
我們正在使用 uv 套件管理器來安裝 Weblate。

```sh
curl -LsSf https://astral.sh/uv/install.sh | sh
```

#### SEE ALSO
[安裝 uv](https://docs.astral.sh/uv/getting-started/installation/)

### Python 模組

#### HINT
我們正在單獨的 Python 環境中安裝 Weblate。

1. 為 Weblate 建立 Python 環境：
   ```sh
   uv venv ~/weblate-env
   ```
2. 為 Weblate 啟動 Python 環境：
   ```sh
   . ~/weblate-env/bin/activate
   ```
3. 安裝 Weblate，包括所有選用相依套件：
   ```sh
   # Install Weblate with all optional dependencies
   uv pip install "weblate[all]"
   ```

   請檢視 [Python 相依套件](https://docs.weblate.org/zh-tw/latest/admin/install.md#python-deps) 以瞭解對選用依賴關係的微調情況。

#### SEE ALSO
* [使用 Python 環境](https://docs.astral.sh/uv/pip/environments/)
* [pip 安裝疑難排解](https://docs.weblate.org/zh-tw/latest/admin/install.md#troubleshoot-pip-install)

### 設定 Weblate

#### NOTE
以下內容假設 Weblate 使用的 Python 環境已經啟用（可以透過 `. ~/weblate-env/bin/activate` 來達成）。如果沒有，請指定 **weblate** 指令的完整路徑為 `~/weblate-env/bin/weblate`。

1. 將檔案 `~/weblate-env/lib/python3.9/site-packages/weblate/settings_example.py` 複製為 `~/weblate-env/lib/python3.9/site-packages/weblate/settings.py`。
2. 將新的 `settings.py` 檔案中的值調整為您所需要的。您至少需要提供資料庫憑證和 Django 金鑰，但在生產安裝中需要做更多的變更，參閱：[調整設定](https://docs.weblate.org/zh-tw/latest/admin/install.md#configuration)。
3. 為 Weblate 建立資料庫及其結構（範例中的設定使用 PostgreSQL，已經準備好的生產設定請檢視 [適用於 Weblate 的資料庫設定](https://docs.weblate.org/zh-tw/latest/admin/install.md#database-setup)）：
   ```sh
   weblate migrate
   ```

   #### SEE ALSO
   [`migrate`](https://docs.weblate.org/zh-tw/latest/admin/management.md#weblate-admin-migrate)
4. 建立管理員使用者帳號 `admin`，產生帳號密碼並將密碼複製到剪貼簿；記得儲存密碼供日後使用：
   ```sh
   weblate createadmin
   ```

   #### HINT
   如果您之前丟失了 admin 密碼，可以使用以下指令產生一個新的 admin 密碼：
   ```sh
   weblate createadmin --update
   ```

   #### SEE ALSO
   [`createadmin`](https://docs.weblate.org/zh-tw/latest/admin/management.md#weblate-admin-createadmin)
5. 為您的收集 Web 伺服器用的靜態檔案（請參閱 [執行伺服器](https://docs.weblate.org/zh-tw/latest/admin/install.md#server) 和 [提供靜態檔案](https://docs.weblate.org/zh-tw/latest/admin/install.md#static-files)）：
   ```sh
   weblate collectstatic
   ```
6. 啟動 Celery 工作程序。這對開發來說是不必要的，但強烈建議在其他場景這樣做。更多資訊請參閱 [使用 Celery 的背景工作](https://docs.weblate.org/zh-tw/latest/admin/install.md#celery)：
   ```sh
   celery --app=weblate.utils worker --beat \
       --queues=celery,notify,memory,translate,backup \
       --prefetch-multiplier=1
   ```
7. 啟動開發伺服器（生產設定請參閱 [執行伺服器](https://docs.weblate.org/zh-tw/latest/admin/install.md#server) ）：
   ```sh
   weblate runserver
   ```

## 安裝後

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

* 您可以在 `http://localhost:8000/` 存取 Weblate。
* 使用安裝期間獲得的管理憑證登入或註冊新使用者。
* 現在當 Weblate 的 Python 環境啟用時，您可以使用 **weblate** 來執行 Weblate 指令，請參閱 [管理指令](https://docs.weblate.org/zh-tw/latest/admin/management.md#manage)。
* 您可以使用 `Ctrl`+`C` 停止測試的伺服器。
* 要檢查您安裝的潛在問題，有兩個途徑。一是 `/manage/performance/` URL (參閱 [效能報告](https://docs.weblate.org/zh-tw/latest/admin/admin.md#manage-performance))，二是使用 **weblate check --deploy**，參閱 [生產設定](https://docs.weblate.org/zh-tw/latest/admin/install.md#production)。

### 新增翻譯

1. 開啟管理介面（ `http://localhost:8000/create/project/` ），並新增您想要翻譯的專案。更多細節請參閱 [專案設定](https://docs.weblate.org/zh-tw/latest/admin/projects.md#project)。

   這裡所有需要您指定的只是專案名稱及其網站。
2. 建立一個組件，該組件是要翻譯的實際物件——它指向版本控制系統儲存庫，並選擇要翻譯的檔案。更多詳細資訊請參閱 [組件設定](https://docs.weblate.org/zh-tw/latest/admin/projects.md#component)。

   此處的重要欄位為：[組件名稱](https://docs.weblate.org/zh-tw/latest/admin/projects.md#component-name)、[原始碼儲存庫](https://docs.weblate.org/zh-tw/latest/admin/projects.md#component-repo) 及用於尋找可翻譯檔案的 [檔案遮罩](https://docs.weblate.org/zh-tw/latest/admin/projects.md#component-filemask)。Weblate 支援多種格式，包括 [GNU gettext PO (Portable Object)](https://docs.weblate.org/zh-tw/latest/formats/gettext.md#gettext)、[Android 字串資源](https://docs.weblate.org/zh-tw/latest/formats/android.md#aresource)、[Apple iOS 字串](https://docs.weblate.org/zh-tw/latest/formats/apple.md#apple)、[Java properties](https://docs.weblate.org/zh-tw/latest/formats/java.md#javaprop)、[Stringsdict 格式](https://docs.weblate.org/zh-tw/latest/formats/stringsdict.md#stringsdict) 或 [Fluent 格式](https://docs.weblate.org/zh-tw/latest/formats/fluent.md#fluent)，更多細節見 [在地化檔案格式](https://docs.weblate.org/zh-tw/latest/formats.md#formats)。
3. 一旦完成上面的工作（根據您的版本控制系統 VCS 儲存庫的大小，以及需要翻譯的資訊數量，這可能是個漫長的過程），您就可以開始翻譯了。
