Skip to main content

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

Release files for kubejs-string-extractor 1.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for kubejs-string-extractor 1.0.10
File Size Uploaded
kubejs_string_extractor-1.0.10.tar.gz 10.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for kubejs-string-extractor 1.0.10
File Interpreter ABI Platform
kubejs_string_extractor-1.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 24.5 kB

Release files / kubejs_string_extractor-1.0.10.tar.gz

Download URL kubejs_string_extractor-1.0.10.tar.gz
Size 10.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7dd2646447aa8d8a916f64001773707f79ad24b688648a1f878e00537b36a860
BLAKE2b-256 checksum
How to use checksums
21bb795e0d73c60719eddbba0233ce536f585c82c74c038b0b24adf8b4f33801
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.

Transparency log

Release files / kubejs_string_extractor-1.0.10-py3-none-any.whl

Download URL kubejs_string_extractor-1.0.10-py3-none-any.whl
Size 14.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
66e6be52bb693cf1cfb9b15d5bbc0365cae544c2800855f6274e611b5ce4b5e0
BLAKE2b-256 checksum
How to use checksums
b100672e4a5491e1ca7af3f5fff18ab0d85511a93a2b9d59338daf48e876323f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Feb 28, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.0.10 This release

2 release files

1.0.9

2 release files

1.0.7

2 release files

1.0.1

2 release files

1.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page