A command-line tool for managing application localization and generating translations using machine translation services.
Project description
transctl
A pragmatic localization CLI ⚙️
transctl is a command-line tool for managing application translation workflows. It scans source files, extracts translatable content, translates it using a configured machine translation provider, and writes translated output files according to your project structure.
The tool maintains a local manifest and translation memory to avoid unnecessary retranslations across runs.
Installation
Requires Python ≥ 3.11.
Install from PyPI:
pip install transctl
Quick Start
Initialize a configuration file:
transctl init
Run the translation workflow:
transctl run
That’s the minimal happy path.
Use:
transctl --help
to explore additional commands.
What It Does
transctl:
- Scans configured resource directories
- Extracts translatable content from files
- Translates content into one or more target locales
- Writes translated output files (never overwrites the source file)
- Skips unchanged files using a generated
manifest.json - Maintains a local SQLite-based translation memory
- Supports optional glossary injection
- Supports placeholder protection using
{{placeholder}}syntax
Avoiding Unnecessary Retranslations
Two mechanisms are used:
1. Translation Manifest (manifest.json)
After each run, a manifest.json file is generated automatically.
It tracks file state to skip unchanged files in subsequent runs.
If the manifest is deleted or purged, files may be reprocessed.
2. Local Translation Memory (SQLite)
A local SQLite database stores translated segments to prevent repeated translation of identical content across runs.
- Automatically created and maintained
- Oldest entries may be pruned when the file grows too large
- Can be purged manually via
transctl purge
If deleted, memory will rebuild over time.
Configuration
The .transctl.toml file is required for operation.
If transctl init is executed and a configuration file already exists, no changes are made.
Example Configuration
[locale]
source = "en"
targets = [
"fr",
]
[engine]
provider = "deepl"
[resources.html]
dirs = [
{ path = "templates/*", layout = "along-sided" }
]
[resources.json]
dirs = [
{ path = "locales/[source].*.json"}
]
Locale
[locale]
source = "en"
targets = ["fr"]
source— source languagetargets— one or more target languages
Engine
[engine]
provider = "deepl"
Supported providers:
deeplazure
Engine-specific parameters can be provided interactively or via CLI flags.
Note: The auth_key of all engines must be provided as an environment variable.
DeepL
Required parameters: None
Example (non-interactive):
transctl init -y \
-e deepl
Azure
Required parameters:
region— Azure resource region
Example (non-interactive):
transctl init -y \
-e azure \
--param region=$AZURE_REGION
Resources
Resources define what files should be translated.
Currently supported:
- HTML
- JSON
Example:
[resources.json]
dirs = [
{ path = "locales/*", layout = "along-sided" },
]
Layout Behavior
layout determines where translated files are written.
Allowed values:
along-sidedby-language
If omitted, the default behavior is equivalent to along-sided.
Note that layout="" is not valid and will result in an error.
along-sided
If the original file is:
i18n.json
The translated file becomes:
fr_i18n.json
by-language
Keeps the original filename but creates a language directory:
locales/en/i18n.json
→
locales/fr/i18n.json
Placeholder Protection
To prevent specific content from being translated, wrap it in:
{{placeholder}}
Anything inside {{}} is preserved.
Glossary Support
A glossary file can be provided as a simple JSON key-value mapping.
Example:
{
"Key": "Value"
}
Contributing
Contributions are welcome.
Please:
- Keep code fully type-annotated
- Add docstrings to public functions and classes
- Include tests for business logic
- Follow existing structure and conventions
Refer to the pull request template for contribution guidelines.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file transctl-1.0.1.tar.gz.
File metadata
- Download URL: transctl-1.0.1.tar.gz
- Upload date:
- Size: 29.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
447c029d7053d94c3f14f0fec82c9f6832cd0bdca6e3c7ae2e84ecf97ece1b15
|
|
| MD5 |
8f7591cace4a88c154e0c3d0da449af6
|
|
| BLAKE2b-256 |
4a02388fb65281c55ed91b515759b76e0b0c48a9630b17ae77f9fda25ee44e2d
|
Provenance
The following attestation bundles were made for transctl-1.0.1.tar.gz:
Publisher:
pypi_release.yml on Gycks/Transctl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
transctl-1.0.1.tar.gz -
Subject digest:
447c029d7053d94c3f14f0fec82c9f6832cd0bdca6e3c7ae2e84ecf97ece1b15 - Sigstore transparency entry: 969365061
- Sigstore integration time:
-
Permalink:
Gycks/Transctl@c25c06607070268e0a34b9536f57f9b9a93832c2 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Gycks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_release.yml@c25c06607070268e0a34b9536f57f9b9a93832c2 -
Trigger Event:
push
-
Statement type:
File details
Details for the file transctl-1.0.1-py3-none-any.whl.
File metadata
- Download URL: transctl-1.0.1-py3-none-any.whl
- Upload date:
- Size: 39.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ab481d4eb8cdd2674ed1684dc64a00e9602a7abf0582a49f7aca9705cf4c5b8f
|
|
| MD5 |
b9cc88f09e31b1e8f222e9c76288e34e
|
|
| BLAKE2b-256 |
adb1a1d4079805c89649518e405fbf65766f3c703217bce29619019a36722e55
|
Provenance
The following attestation bundles were made for transctl-1.0.1-py3-none-any.whl:
Publisher:
pypi_release.yml on Gycks/Transctl
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
transctl-1.0.1-py3-none-any.whl -
Subject digest:
ab481d4eb8cdd2674ed1684dc64a00e9602a7abf0582a49f7aca9705cf4c5b8f - Sigstore transparency entry: 969365096
- Sigstore integration time:
-
Permalink:
Gycks/Transctl@c25c06607070268e0a34b9536f57f9b9a93832c2 -
Branch / Tag:
refs/tags/v1.0.1 - Owner: https://github.com/Gycks
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
pypi_release.yml@c25c06607070268e0a34b9536f57f9b9a93832c2 -
Trigger Event:
push
-
Statement type: