Tools for working with frontend localization files.
Find a file
Cohee 46d4840369
Merge pull request #10 from Tosd0/main
fix: extract data-i18n keys from more patterns and improved styling
2026-02-19 14:37:28 +02:00
generate.py fix: keep first duplicate key and add DUP stats 2026-02-19 01:46:05 +08:00
LICENSE Initial commit 2024-06-01 20:49:05 +03:00
README.md feat(sort-keys): use first appearance to sort keys in file 2026-02-18 02:55:41 +08:00
requirements.txt https://github.com/SillyTavern/SillyTavern/pull/4180#discussion_r2154607758 2025-06-19 15:10:28 +08:00
update-i18n(zh-cn,tw).py https://github.com/SillyTavern/SillyTavern/pull/4180#discussion_r2154607758 2025-06-19 15:10:28 +08:00

SillyTavern-i18n

Tools for working with frontend localization files.

Features

  1. Automatically add new keys from HTML data-i18n attributes.
  2. Extract keys from scripts (t template tag and translate(...)).
  3. Prune missing keys from localization files.
  4. Use automatic Google translation to auto-populate missing values.
  5. Sort JSON files by project tree order (source path + first appearance in file).

Usage

usage: generate.py [-h] [-d DIRECTORY] [--auto-add] [--auto-translate] [--auto-remove] [--sort-keys]
                   json

Update or Generate i18n JSON files

positional arguments:
  json                  JSON file path

options:
  -h, --help            show this help message and exit
  -d DIRECTORY, --directory DIRECTORY
                        Directory path
  --auto-add            Auto add missing keys
  --auto-translate      Auto translate missing keys when they are added
  --auto-remove         Auto remove extra keys
  --sort-keys           Sort keys by project tree order (source path + first appearance in file)

Dependencies: Python 3.10 and up.

  1. Install the requirements.
pip install -r ./requirements.txt
  1. Run generate.py while in the SillyTavern directory.

Example (update for zh-cn file, sort keys):

cd ~/SillyTavern
python ~/SillyTavern-i18n/generate.py zh-cn --sort-keys
  1. Commit and PR changes to the SillyTavern repository.

License and credits

AGPLv3