在調查多國語系時發現了 Tolgee,它提供雲端和自架的方案,Self-hosted Pricing | Tolgee

開發環境
- Windows 11 Home
- docker tolgee/tolgee:v3.83.3
- docker postgres:17
安裝
自架我選用 docker,可以參考官方資訊 Running with Docker | Tolgee
官方文件建議在單一容器執行 Tolgee
docker run -v tolgee_data:/data/ -p 8085:8080 tolgee/tolgee
我選用 docker-compose.yml 內容如下
version: '3'
services:
app:
image: tolgee/tolgee:v3.83.3
volumes:
- ./data:/data
- ./config.yaml:/config.yaml
ports:
- '8085:8080'
environment:
spring.config.additional-location: file:///config.yaml # <--- this line
deploy:
restart_policy:
condition: on-failure
depends_on:
- db
db:
image: postgres:17
environment:
POSTGRES_DB: postgres
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
volumes:
- ./data/postgres:/var/lib/postgresql/data
ports:
- '5432:5432' # <-- If you want to access your postgres from outside of docker network\
config.yaml 內容如下
tolgee:
authentication:
enabled: true
initial-password: admin
initial-username: admin
# jwt-secret: my_jwt_secret
machine-translation:
# google:
# api-key: my_google_api_key
deepl:
auth-key: my_deepl_api_key
smtp:
auth: true
from: Tolgee <no-reply@mydomain.com>
host: email-smtp.regional-region.amazonaws.com
password: admin
port: 465
ssl-enabled: true
username: user@company.com
postgres-autostart:
enabled: false
spring:
datasource:
url: jdbc:postgresql://db:5432/postgres
username: postgres
password: postgres
啟動服務
docker-compose up
使用 admin/admin 登入系統
登入後,就可以看到預設頁面

Server configuration
由於 Server 是基於 Spring 框架,所以遵循 Spring 框架的配置標準。可以透過提供設定檔來設定 Tolgee,在使用 java -jar 命令執行 Tolgee 時將設定屬性作為命令列參數提供,或作為環境變數提供。

更多的參數請參考 Server configuration | Tolgee
使用 Tolgee
Toglee 有很多的功能,在這裡我列出我需要的功能,其餘的就到官網看吧
API Key
要能使用 API 就需要先產生 API Key
http://localhost:8085/account/apiKeys

上傳語系檔
支援多種格式

josn 範例檔如下,名為 zh-tw.json
{
"add-item-button": "加入",
"edit-item-button": "編輯"
}
匯出語系檔
介面本身就提供 http://localhost:8085/projects/1/export,可以直接點選你需要的語系下載 zip

或是透過 API http://localhost:8085/projects/1/integrate,

curl "http://localhost:8085/v2/projects/export?ak=tgpak_gfpte5bumvzde2lcovxtkztwof2wumdnobtgioljnnzw2" --output data.zip
Tolgee 提供了非常多的 API https://docs.tolgee.io/api/
Export 的章節內容 https://docs.tolgee.io/api/export-data
curl -L -X GET 'http://localhost:8085/v2/projects/1/export' --output data.zip `
-H 'Accept: application/json' `
-H 'X-API-Key: tgpak_gfpte5bumvzde2lcovxtkztwof2wumdnobtgioljnnzw2'
機器翻譯
Tolgee 支援以下幾種翻譯
- AWS Amazon Translate
- Azure Cognitive Translation
- Baidu Translate
- DeepL
- Google Cloud Translation
- tolgee
https://docs.tolgee.io/platform/self_hosting/configuration#machine-translation

只要配置好相關的 key 就可以使用了,使用步驟如下:

翻譯目標截圖
翻譯人員跟開發團隊可能不是同一組人,如果有應用程式畫面,能讓翻譯人原知道上下文,翻譯的精準度會更高

心得
tolgee 使用起來真的簡單,好的管理介面可以處理多國語系,解決了我多年來的問題
範例位置
若有謬誤,煩請告知,新手發帖請多包涵
Microsoft MVP Award 2010~2017 C# 第四季
Microsoft MVP Award 2018~2022 .NET