๐ stewbeet.plugins.auto.lang_file
๐ Source Code: stewbeet/plugins/auto/lang_file/__init__.py ๐
๐ Source Code: stewbeet/plugins/auto/lang_file/utils.py ๐
๐ Dependencies
- โ Required: Beet context with functions, loot tables, advancements, recipes, etc.
- โ Required: Project ID for translation key namespacing
- ๐ Position: Should run after content generation but before finalization
- ๐ง Optional: Existing
en_us.jsonlanguage file (will be merged) - ๐ Related: Works with any plugins that generate text content
๐ Overview
The auto.lang_file plugin automatically generates language files for datapacks.
It scans all functions and loot tables for hardcoded text strings, extracts them into
translation keys, replaces the original text with translate text component keys, and generates
a comprehensive en_us.json language file for internationalization support.
Feature Showcase
Before and after lang plugin:

Generated en_us.json lang file:

๐ฏ Purpose
- ๐ Automatically generates language files from hardcoded text
- ๐ Converts
"text"text component keys to"translate"keys - ๐ Extracts text strings from functions and loot tables
- ๐ท๏ธ Creates standardized translation keys with project namespacing
- ๐งน Cleans and validates text content for language file inclusion
- ๐ Enables internationalization support for datapacks
โ๏ธ Configuration
๐ฏ Basic Example Configuration
pipeline: - ... - stewbeet.plugins.auto.lang_file - ... # No configuration required - plugin runs automatically # Processes all text files by default (functions, loot tables, advancements, etc.)
๐ Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
| Text Extraction | automatic | Enabled | Scans all "text" fields in file content |
| Key Generation | automatic | Project-based | Uses project ID for translation key prefixes |
| Parallel Processing | automatic | 32 workers | Multi-threaded file processing for performance |
| Language Target | constant | en_us | Generates English language file by default |
โจ Features
๐ Text Extraction Engine
Scans content for hardcoded text using regex patterns:
- ๐ Uses advanced regex to find
"text": "value"patterns - ๐ Handles escaped characters and various quote styles
- ๐ Tracks text positions for accurate replacement
- ๐ฏ Processes both single and double quoted strings
๐ท๏ธ Translation Key Generation
Creates standardized translation keys with project namespacing:
- ๐งน Cleans text by removing special characters and normalizing case
- ๐ Limits key length to 64 characters for compatibility
- ๐ง Uses project ID prefix for unique namespacing
- โ Validates keys to ensure they contain meaningful content
๐ Content Replacement System
Replaces hardcoded text with translate components:
- ๐ Converts
"text": "value"to"translate": "key" - ๐ Processes matches in reverse order to maintain position accuracy
- ๐งน Handles escape sequences and special characters properly
- โ Preserves JSON structure and formatting during replacement
๐ Parallel Processing System
Efficiently processes multiple files using multi-threading:
- โก Uses up to 32 worker threads for fast processing
- ๐ Processes both functions and loot tables simultaneously
- ๐จ Provides colored progress indicators during execution
- ๐ง Optimizes worker count based on file quantity
๐ Language File Management
Generates and updates the English language file:
- ๐ Creates
minecraft:en_uslanguage resource - ๐ Merges with existing language data if present
- ๐พ Uses proper JSON formatting for compatibility
- ๐ Sets up foundation for multi-language support
๐งน Content Validation System
Ensures only meaningful text gets processed:
- โ Skips text without alphanumeric characters
- ๐ Validates minimum key length requirements
- ๐ซ Excludes Unicode escapes and template variables
- ๐ฏ Prevents duplicate keys with conflicting values