Skip to main content

Extract translatable strings from Minecraft modpack KubeJS scripts and output them as resource pack lang JSON files.

Project description

KubeJS String Extractor

Extract translatable strings from Minecraft modpack KubeJS scripts, rewrite the JS files to use Text.translatable(), and output en_us.json lang files for localization.

What it does

KubeJS scripts often contain hardcoded English strings (item names, tooltips, ponder text, announcements, etc.) that are not translatable via standard Minecraft resource packs. This tool:

  1. Scans client_scripts/, server_scripts/, and startup_scripts/ for translatable strings
  2. Extracts strings from patterns like .displayName(), Text.of(), Text.red(), scene.text(), addAnnouncement(), etc.
  3. Rewrites the original JS files to use Text.translatable('key') calls
  4. Outputs a standard en_us.json lang file for translators to work with

Supported Patterns

Original Rewritten As
.displayName('Foo') .displayName(Text.translatable('key'))
Text.of('Foo') Text.translatable('key')
Text.red('Foo') Text.translatable('key').red()
Text.green/blue/yellow/gold('Foo') Text.translatable('key').green/blue/yellow/gold()
scene.text(N, 'Foo', ...) scene.text(N, Text.translatable('key'), ...)
addAnnouncement("ver", "Foo") addAnnouncement("ver", Text.translatable('key'))
.append('Foo') .append(Text.translatable('key'))
.statusMessage = "Foo" .statusMessage = Text.translatable('key')
.tell("Foo") .tell(Text.translatable('key'))

Installation

pip install kubejs-string-extractor

Or with uv:

uv tool install kubejs-string-extractor

Usage

# Extract strings, rewrite JS files, and generate en_us.json
kubejs-strings extract path/to/kubejs

# Custom output directory
kubejs-strings extract path/to/kubejs --output my_translations

# Extract only (no JS rewriting)
kubejs-strings extract path/to/kubejs --no-rewrite

# Modify original JS files in place (⚠️ make backups first!)
kubejs-strings extract path/to/kubejs --in-place

# Custom namespace prefix for translation keys
kubejs-strings extract path/to/kubejs --namespace mypack

Output

extracted/
├── assets/
│   └── kubejs_string_extractor/
│       └── lang/
│           └── en_us.json          # Translation keys → English strings
└── kubejs/                         # Rewritten JS files (unless --no-rewrite)
    ├── client_scripts/
    ├── server_scripts/
    └── startup_scripts/

The en_us.json contains entries like:

{
  "kubejs.client.tooltips.1": "Place the pad down in the specified Dimension",
  "kubejs.startup.universal_press.1": "Inscriber Universal Press"
}

Workflow

  1. Run the tool to extract strings and rewrite JS files
  2. Copy the rewritten JS files back into your modpack's kubejs/ directory
  3. Place en_us.json in your resource pack
  4. Create zh_cn.json (or other locales) by translating the values

Development

# Install dependencies
uv sync

# Run tests
uv run pytest tests/ -v

# Run against sample data
uv run kubejs-strings extract output/kubejs --output test_output

License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

kubejs_string_extractor-1.0.1.tar.gz (8.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

kubejs_string_extractor-1.0.1-py3-none-any.whl (11.7 kB view details)

Uploaded Python 3

File details

Details for the file kubejs_string_extractor-1.0.1.tar.gz.

File metadata

  • Download URL: kubejs_string_extractor-1.0.1.tar.gz
  • Upload date:
  • Size: 8.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for kubejs_string_extractor-1.0.1.tar.gz
Algorithm Hash digest
SHA256 36fcc5967c65f265366fd09234e1a1d8eceddc8253fe0b2bc9ff425b64c8d816
MD5 0cddcd9c76ffc4a71a8362f563a19590
BLAKE2b-256 ef25a9ba438e17148000066b06c24e00ac276f3032dc8ffca24c7682e6520eb8

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubejs_string_extractor-1.0.1.tar.gz:

Publisher: publish.yml on zack-zzq/kubejs-string-extractor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file kubejs_string_extractor-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for kubejs_string_extractor-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 655d963c79f6631985d255a613aa09f8912a8c202b56b9b0526dc97b1b8f6e4e
MD5 2cb05180798df9629c419b3ec3394cfe
BLAKE2b-256 8763bc939d83d1d8de569af6a09f4038390433e71f70947d7258083bf5d13da2

See more details on using hashes here.

Provenance

The following attestation bundles were made for kubejs_string_extractor-1.0.1-py3-none-any.whl:

Publisher: publish.yml on zack-zzq/kubejs-string-extractor

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page