Skip to main content

Python library for working with Unreal Engine .locres translation files.

Project description

🧩 PyLocres

Unreal Engine PyPI PyPI - Python Version License Downloads

PyLocres is a Python library for reading, writing, and editing .locres and .locmeta files used in Unreal Engine's localization system.
Supports all known versions of Locres, including the latest.


📦 Installation

Install from PyPI:

pip install pylocres

Or install directly from the repository:

git clone https://github.com/stas96111/pylocres.git
cd pylocres
pip install -r requirements.txt
pip install .

🛠️ Command Line Tool

# Show info about a .locres file
pylocres info --path example.locres

# Convert .locres to .csv
pylocres to-csv --path example.locres --out output.csv

# Convert .csv to .locres
pylocres from-csv --path output.csv --out result.locres

# Convert .locres to .po
pylocres to-po --path example.locres --out output.po

# Convert .po to .locres
pylocres from-po --path output.po --out result.locres

📘 Usage: Locres

from pylocres import LocresFile, Namespace, Entry, LocresVersion, entry_hash

# Create Locres file instance
locres = LocresFile()

# Read a .locres file
locres.read("path/to/file.locres")

# Iterate over all namespaces
for namespace in locres:
    print("Namespace:", namespace.name or "<default>")

    # Iterate over all entries in the namespace
    for entry in namespace:
        print("Key:", entry.key) # cf433749-2e... (uuid4 or custom key)
        print("Translation:", entry.translation) # Hello world!
        print("Source Hash:", entry.hash) # 828975897

        # Set a new translation
        entry.translation = "Привіт світ!"

        # Optionally, recalculate source hash
        entry.hash = entry_hash("Hello world!")

# Create a new entry and add it to a namespace
new_entry = Entry("my_key", "My translation", entry_hash("My source"))
namespace.add(new_entry)

# Add a new namespace
new_namespace = Namespace("UI")
locres.add(new_namespace)

# Set file format version (default: CityHash)
locres.version = LocresVersion.CityHash

# Save the modified locres file
locres.write("path/to/output.locres")

# Done

Locmeta Usage

from pylocres import LocmetaFile, LocmetaVersion

# Create Locmeta file instance
locmeta = LocmetaFile()

# Read a .locmeta file
locmeta.read("path/to/file.locmeta")

# View metadata
print("Version:", locmeta.version)
print("Native culture:", locmeta.native_culture) # en
print("Native locres path:", locmeta.native_locres) # en/Game.locres
print("Compiled cultures:", locmeta.compiled_cultures) # ["en", "de", "fr", ...]

# Modify metadata
locmeta.native_culture = "uk"

# Save changes
locmeta.write("path/to/output.locmeta")

# Done

License

MIT License © 2025 stas96111

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

pylocres-0.1.9.1.tar.gz (16.9 kB view details)

Uploaded Source

Built Distribution

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

pylocres-0.1.9.1-py3-none-any.whl (15.4 kB view details)

Uploaded Python 3

File details

Details for the file pylocres-0.1.9.1.tar.gz.

File metadata

  • Download URL: pylocres-0.1.9.1.tar.gz
  • Upload date:
  • Size: 16.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for pylocres-0.1.9.1.tar.gz
Algorithm Hash digest
SHA256 51c23f4495f8b98784ca24c705d0a72f7bb29937ddd24eb483f9c769afb33c3f
MD5 2371a2bd06051dea491a86c25360a460
BLAKE2b-256 e5efa40a04344ce4b32c2e8dd8550c7aa3a06effb99b4c0dee2ea21dade21006

See more details on using hashes here.

File details

Details for the file pylocres-0.1.9.1-py3-none-any.whl.

File metadata

  • Download URL: pylocres-0.1.9.1-py3-none-any.whl
  • Upload date:
  • Size: 15.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.6

File hashes

Hashes for pylocres-0.1.9.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7de468e894a55473aca1fe2a2adcaa07f532b0239fe2c44948f9d6b5176c7287
MD5 00fe0c031d606f106520738b11983b29
BLAKE2b-256 73d07ac6522927f9b2851cf6bc62bff482080ffb7f9d76b26480702cfa99ba97

See more details on using hashes here.

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