Sourcemod plugin to automatically translate messages in chat to target languages
  • SourcePawn 95.5%
  • TypeScript 3.5%
  • Dockerfile 0.4%
  • Shell 0.4%
  • Pawn 0.2%
Find a file
Jackz a4436db0f2
All checks were successful
Build Image / build (push) Successful in 1m13s
Merge branch 'main' of ssh://git.jackz.me:222/jackz/sm-translate
2026-04-15 16:06:21 -05:00
.forgejo/workflows ci: Don't append zip ext 2026-04-13 08:03:40 -05:00
scripting Update scripting/sm_translate.sp 2026-04-15 15:28:53 -05:00
server Merge branch 'main' of ssh://git.jackz.me:222/jackz/sm-translate 2026-04-15 16:06:21 -05:00
.gitignore add multicolors, ripext, ripext 2026-04-13 07:46:09 -05:00
compile_all.sh ci: add missing file 2026-04-12 20:59:55 -05:00
README.md Update README.md 2026-04-15 14:05:53 -05:00

SM Translate

server workflow status plugin workflow status

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 language
  • sm_lang - Shows current language and prints list of languages to client console
  • sm_lang <lang code/OFF/DEFAULT> - Sets client's target language for translations, or uses game's language (DEFAULT), or disables receiving translations (OFF)

License

MIT License.