Expand description
Mod translation and localization support.
This module provides tools for managing translations of mod content, making it easier to localize mods for different languages. It tracks translation status, detects changes in source text, and supports auto-translation from vanilla data.
§Overview
The translation system works by:
- Extracting all translatable strings from a pack’s Loc files
- Storing translations in a separate JSON file alongside the pack
- Tracking which translations need updating when source text changes
- Auto-translating from vanilla localisation data where possible
§Translation Files
Translations are stored in separate JSON files. Each file contains all source strings and their translations, along with metadata about translation status.
§Auto-Translation
The system can automatically translate strings that exist in the game’s vanilla localisation files. This is useful for mods that reference vanilla content or use similar terminology.
§Workflow
- Create a
PackTranslationfrom a pack - Export to a translation file for external editing
- Import completed translations
- Generate the final translated Loc file for the pack
§Output
Translated strings are output to a Loc file that overrides the original mod’s entries. The filename depends on the game:
- Warhammer 1 and newer (except Thrones):
!!!!!!translated_locs.loc- loads first due to its naming, allowing translations to override the original entries - Thrones of Britannia and older games:
localisation.loc
§Example
use rpfm_extensions::translator::PackTranslation;
// Create translation from pack
let mut translation = PackTranslation::new(
&[translations_path],
&pack,
"warhammer_3",
"EN", // Source language
"ES", // Target language (Spanish)
&dependencies,
&english_base,
&local_fixes,
)?;
// Save translation file
translation.save(&output_path)?;
// Generate translated Loc file for the pack
let loc_file = translation.generate_loc()?;Modules§
- hub
- Submission of translations to the Translation Hub.
Structs§
- Pack
Translation - Translation data for an entire pack.
- Translation
- Translation entry for a single localizable string.
Constants§
- CURRENT_
VERSION - Current on-disk format version. New translations default to this; legacy
files without a
versionfield are still loaded as v0 and saved back as v0 unless the user opts in to the new format from the UI. - DEFAULT_
SRC_ LANG - Two-letter source-language code assumed when none is recorded on disk.
- TRANSLATED_
FILE_ NAME - Filename for the generated translated Loc file.
- TRANSLATED_
PATH - Full path for the translated Loc file within a pack.
- TRANSLATED_
PATH_ OLD - Legacy path for translated Loc files (for backwards compatibility).
- VANILLA_
LOC_ NAME_ EN - Name of the Translation Hub’s TSV with the vanilla English texts.