Skip to main content

A command-line tool to streamline the process of updating language files for Minecraft Java Edition modpacks.

Project description

UpLang

PyPI Python License Downloads

UpLang is a powerful command-line tool designed to streamline localization workflows for Minecraft Java Edition modpacks. It automates the complex process of managing translation files across multiple mods, ensuring perfect synchronization between English and Chinese language files while preserving translation integrity and key ordering.

โš ๏ธ Development Notice: UpLang is currently in active development and rapid iteration. While stable for production use, new features and improvements are being added frequently. Please check the releases page for the latest updates and consider updating regularly to benefit from new features and bug fixes.

๐ŸŒ Languages

English | ็ฎ€ไฝ“ไธญๆ–‡

๐Ÿš€ Key Features

  • ๐Ÿ” Intelligent Mod Detection: Automatically scans and tracks new, updated, and deleted mods
  • ๐Ÿ”„ Smart Synchronization: Maintains translation order while adding missing keys and removing obsolete ones
  • ๐Ÿ›ก๏ธ Robust Error Handling: Advanced JSON parsing with multiple fallback strategies for malformed files
  • ๐Ÿ“Š Progress Tracking: Rich console interface with real-time progress indicators
  • ๐ŸŒ Cross-Platform: Works seamlessly on Windows, macOS, and Linux
  • โšก Incremental Updates: Efficient delta processing for large modpacks
  • ๐ŸŽฏ Order Preservation: Maintains original key ordering in language files
  • ๐Ÿ“š Professional Documentation: Comprehensive docstrings and code comments
  • ๐Ÿ”ง Dependency Injection: Clean architecture with testable components

๐Ÿ“‹ System Requirements

  • Python: 3.11 or higher
  • Operating System: Windows, macOS, or Linux
  • Minecraft: Java Edition (Forge/Fabric mods)

๐Ÿ› ๏ธ Installation

Option 1: From PyPI (Recommended)

The easiest way to install UpLang is directly from PyPI:

# Install UpLang
pip install uplang

# Verify installation
uplang --help

Option 2: Development Installation

For contributing or development purposes:

# Clone the repository
git clone https://github.com/QianFuv/UpLang.git
cd UpLang

# Using uv (recommended for development)
pip install uv
uv sync
uv pip install -e .

# Or using pip directly
pip install -e .

๐Ÿ“– Usage

Initial Setup

For new projects or when setting up a new resource pack:

uplang init <mods_directory> <resource_pack_directory>

Example:

uplang init "~/.minecraft/mods" "./MyResourcePack"

What it does:

  • ๐Ÿ” Scans all JAR files in the mods directory
  • ๐Ÿ“‚ Creates the necessary assets/<mod_id>/lang/ structure
  • ๐Ÿ“„ Extracts en_us.json from each mod
  • ๐Ÿ”„ Copies or creates zh_cn.json files
  • โš™๏ธ Performs initial synchronization
  • ๐Ÿ’พ Saves project state for future comparisons

Updating Translations

When you add, update, or remove mods:

uplang check <mods_directory> <resource_pack_directory>

Example:

uplang check "~/.minecraft/mods" "./MyResourcePack"

What it does:

  • ๐Ÿ“Š Compares current state with previous scan
  • ๐Ÿ†• Identifies new, updated, and deleted mods
  • ๐Ÿ”„ Merges new translation keys into existing files
  • ๐Ÿงน Removes obsolete keys
  • โœ… Synchronizes all language files
  • ๐Ÿ’พ Updates project state

๐Ÿ“ Output Structure

After running UpLang, your resource pack will have this structure:

MyResourcePack/
โ”œโ”€โ”€ assets/
โ”‚   โ”œโ”€โ”€ mod_one/
โ”‚   โ”‚   โ””โ”€โ”€ lang/
โ”‚   โ”‚       โ”œโ”€โ”€ en_us.json
โ”‚   โ”‚       โ””โ”€โ”€ zh_cn.json
โ”‚   โ”œโ”€โ”€ mod_two/
โ”‚   โ”‚   โ””โ”€โ”€ lang/
โ”‚   โ”‚       โ”œโ”€โ”€ en_us.json
โ”‚   โ”‚       โ””โ”€โ”€ zh_cn.json
โ”‚   โ””โ”€โ”€ ...
โ”œโ”€โ”€ pack.mcmeta (if it exists)
โ”œโ”€โ”€ .uplang_state.json (project state)
โ””โ”€โ”€ uplang_*.log (operation logs)

๐Ÿงช Testing

Run the comprehensive test suite to verify everything works correctly:

# Run all tests
PYTHONPATH=src python -m pytest tests/ -v

# Run with coverage report
PYTHONPATH=src python -m pytest tests/ --cov=uplang --cov-report=html

# Run specific test modules
PYTHONPATH=src python -m pytest tests/test_json_utils.py -v    # JSON processing tests
PYTHONPATH=src python -m pytest tests/test_models.py -v        # Data model tests
PYTHONPATH=src python -m pytest tests/test_utils.py -v         # Utility function tests

# If using development installation with uv
uv run pytest tests/ -v

The test suite includes:

  • Data Model Testing: Comprehensive validation of mod objects, comparison results, and sync statistics
  • JSON Processing: Robust parsing with encoding fallbacks, malformed JSON recovery, and order preservation
  • Utility Functions: Filename sanitization, mod ID creation, and path handling
  • Error Handling: Edge cases, invalid inputs, and graceful recovery strategies
  • Unicode Support: International characters, emoji, and encoding edge cases
  • Order Preservation: Ensures JSON key ordering is maintained during operations

Current Test Coverage

  • โœ… Data Models: Mod metadata, comparison results, synchronization statistics
  • โœ… JSON Processing: Multi-encoding support, malformed JSON recovery, OrderedDict preservation
  • โœ… Utility Functions: Safe filename handling, mod ID generation, string operations
  • โœ… Error Handling: Exception hierarchy and context preservation
  • โœ… Unicode Handling: International character support and encoding fallbacks

๐Ÿ”ง Advanced Features

Robust JSON Processing

UpLang handles real-world edge cases:

  • Multiple encodings: UTF-8, UTF-8-sig, Latin1, CP1252
  • Malformed JSON: Trailing commas, unquoted keys, comments
  • Encoding issues: UTF-8 BOM, surrogate characters
  • Recovery strategies: Multiple parsing fallbacks

Translation Preservation

  • Existing translations are always preserved during synchronization
  • Key ordering follows the English language file structure
  • Incremental updates only process changed files for efficiency
  • Atomic operations ensure data integrity

Code Quality Standards

  • Comprehensive Documentation: All modules, classes, and methods include detailed docstrings
  • Type Safety: Complete type annotations throughout the codebase
  • Error Handling: Hierarchical exception system with context information
  • Clean Architecture: Dependency injection and separation of concerns
  • Professional Standards: Industry-grade code organization and documentation

Logging and Monitoring

  • Detailed logs saved to timestamped files
  • Progress indicators for long-running operations
  • Error reporting with context and suggested solutions
  • State tracking for debugging and auditing

๐Ÿค Contributing

We welcome contributions! Please see our Contributing Guide for details on:

  • ๐Ÿ› Reporting bugs
  • ๐Ÿ’ก Suggesting features
  • ๐Ÿ”ง Setting up development environment
  • ๐Ÿ“ Code style guidelines
  • โœ… Testing requirements

๐Ÿ“„ License

This project is licensed under the MIT License - see the LICENSE file for details.

๐Ÿ™ Acknowledgments

  • Built with Rich for beautiful console output
  • Uses uv for fast dependency management
  • Inspired by the Minecraft modding community's localization needs

๐Ÿ“ž Support


Made with โค๏ธ for the Minecraft modding community

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

uplang-0.2.7.tar.gz (27.2 kB view details)

Uploaded Source

Built Distribution

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

uplang-0.2.7-py3-none-any.whl (36.3 kB view details)

Uploaded Python 3

File details

Details for the file uplang-0.2.7.tar.gz.

File metadata

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

File hashes

Hashes for uplang-0.2.7.tar.gz
Algorithm Hash digest
SHA256 55982121d65b18e84fa1b43930c935734284827f2c6e97ac71f21133ae90f4f8
MD5 fb111de11bfe21ad06dc8aa39bafc660
BLAKE2b-256 b10aa6f36ecb908ff630dfc9a21fb93dd2616e24296fbcad7966ea4093a36529

See more details on using hashes here.

Provenance

The following attestation bundles were made for uplang-0.2.7.tar.gz:

Publisher: publish-to-pypi.yml on QianFuv/UpLang

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

File details

Details for the file uplang-0.2.7-py3-none-any.whl.

File metadata

  • Download URL: uplang-0.2.7-py3-none-any.whl
  • Upload date:
  • Size: 36.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for uplang-0.2.7-py3-none-any.whl
Algorithm Hash digest
SHA256 2ae0617e7326a7b5b176c02202701cbc92aef29341f3e2ac9c0428863204bc8a
MD5 62905dd5cee9291584ce83e6a9d1d3d6
BLAKE2b-256 4cbe2faf117e1ae92764cb22582f688f209fb3b3eb1d5d28cec91e64a6919d64

See more details on using hashes here.

Provenance

The following attestation bundles were made for uplang-0.2.7-py3-none-any.whl:

Publisher: publish-to-pypi.yml on QianFuv/UpLang

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