- SourcePawn 95.5%
- TypeScript 3.5%
- Dockerfile 0.4%
- Shell 0.4%
- Pawn 0.2%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| scripting | ||
| server | ||
| .gitignore | ||
| compile_all.sh | ||
| README.md | ||
SM Translate
Sourcemod plugin that automatically translates messages in chat to all users' target language. Translations are done with Google Cloud Translate v2. A system checks if translation is necessary before even calling the API for a reduction in token usage.
Note
- The server uses franc for detecting languages. By default to reduce false positives, it will not translate any text under 10 characters long.
- Translations are not perfect, nor is language detection. Some messages may show the wrong language or bad translations.
Setup
Requires System 2 extenstion. Some versions of System2 seem to cause crashes with outdated GLIBC libraries.
Plugin
Download plugin from the releases or artifacts pages.
Change sm_translate_api_path (default: http://localhost:5000/translate) as applicable. Config file is at left4dead2/cfg/sourcemod/sm_translate.cfg
Server
Translation server requires an API Key for Google Cloud Translation. I recommend to limit the key by IP address.
By default server listens on http://0.0.0.0:5000, with the API at POST /translate
docker-compose.yaml
services:
translate:
image: git.jackz.me/jackz/translate-server:main
restart: always
environment:
GOOGLE_TRANSLATE_API_KEY: ${GOOGLE_TRANSLATE_API_KEY}
HOST: 0.0.0.0
env_file: .env
ports:
- 5000:5000
cpu_shares: 512
deploy:
resources:
limits:
cpus: "1"
memory: 512M
reservations:
memory: 256M
Commands
sm_t <lang code> <msg>(or /t, !t) - translates message to target languagesm_lang- Shows current language and prints list of languages to client consolesm_lang <lang code/OFF/DEFAULT>- Sets client's target language for translations, or uses game's language (DEFAULT), or disables receiving translations (OFF)