Skip to content

Repository files navigation

MSG2PO

Build statusPatreonTelegramDiscordIRC

A set of tools to convert Fallout 1/2 MSG and WeiDU TRA into GNU gettext PO and back, used in BGforge Hive. Ask questions here.

Table of Contents

Installation

pipx install msg2po

Also install Gettext tools, and make sure they are in PATH.

Configuration

Create a .bgforge.yml file in your project root to configure the tool:

translation:
encoding: cp1252 # source encoding (cp1252 default, cp1251/ru, cp1250/pl, cp1258/vi)tra_dir: "."# translation root directorysrc_lang: "english"# source language (used for poify)extract_format: ""# "" (default), "sfall" for Falloutno_female: false # skip female translationsextract_fuzzy: false # include fuzzy entries

Commands

poify

Converts game translation files (MSG, SVE, TXT, TRA) from a source language directory into a single .pot (PO Template) file.

poify [DIR] [-e ENC] [-v] [-q] [-t]
ArgumentDescriptionDefault
DIRSource language directory./english
-e ENCSource encodingcp1252
-v, --verboseEnable verbose output-
-q, --quietSuppress info messages-
-t, --timestampsShow timestamps in log output-

Example:

poify ./english -e cp1252

This scans the ./english directory for all translation files and creates ./po/english.pot.


unpoify

Extracts translated files from PO files back into the game's directory structure. Used after translation is done in Weblate/PO editor.

unpoify [DIR] [-v] [-q] [-t]
ArgumentDescriptionDefault
DIRDirectory with PO files./po
-v, --verboseEnable verbose output-
-q, --quietSuppress info messages-
-t, --timestampsShow timestamps in log output-

Example:

unpoify ./po

This reads PO files from ./po and extracts translations back into language-specific directories (e.g., ./french/).


file2po

Converts a single game translation file (MSG, SVE, TXT, TRA) into a PO file. Useful for extracting from individual files.

file2po INPUT_SOURCE OUTPUT_PO [-e ENC] [-v] [-q] [-t]
ArgumentDescriptionDefault
INPUT_SOURCEInput translation file-
OUTPUT_POOutput PO file-
-e ENCSource encodingcp1252
-v, --verboseEnable verbose output-
-q, --quietSuppress info messages-
-t, --timestampsShow timestamps in log output-

Example:

file2po ./english/dialog.msg ./output.pot -e cp1252

po2file

Converts PO entries back into a single game translation file. The reverse of file2po.

po2file INPUT_FILE OUTPUT_FILE [-e ENC] [--path PATH] [-v] [-q] [-t]
ArgumentDescriptionDefault
INPUT_FILEInput PO file-
OUTPUT_FILEOutput translation file-
-e ENCOutput encodingcp1252
--path PATHFile occurrence in PO (relative path)Output filename
-v, --verboseEnable verbose output-
-q, --quietSuppress info messages-
-t, --timestampsShow timestamps in log output-

Example:

po2file ./french.po ./french/dialog.msg -e cp1252

file2msgstr

Loads translations from a game translation file into the msgstr fields of an existing PO file. Useful for reloading edited translations.

file2msgstr INPUT_FILE OUTPUT_FILE [-e ENC] [--path PATH] [--overwrite] [--same] [-v] [-q] [-t]
ArgumentDescriptionDefault
INPUT_FILEInput translation file-
OUTPUT_FILEOutput PO file (must exist)-
-e ENCSource encodingcp1252
--path PATHPO occurrence pathInput filename
--overwriteOverwrite existing translations-
--sameLoad translations identical to original strings-
-v, --verboseEnable verbose output-
-q, --quietSuppress info messages-
-t, --timestampsShow timestamps in log output-

Example:

file2msgstr ./french/dialog.msg ./french.po --overwrite

dir2msgstr

Batch loads translations from all files in a directory into corresponding PO files. Reverse of unpoify - used when translators edit files directly instead of PO.

dir2msgstr [--auto] [-s SRC_DIR] [-o OUTPUT_FILE] [--ext EXT] [--same] [--overwrite] [-v] [-q] [-t]
ArgumentDescriptionDefault
--autoAuto-find POs and language dirs, process all valid extensions-
-s SRC_DIRDirectory to load from.
-o OUTPUT_FILEExisting PO file-
--ext EXTLoad files with this extension-
--sameLoad translations identical to original strings-
--overwriteOverwrite existing translations-
-v, --verboseEnable verbose output-
-q, --quietSuppress info messages-
-t, --timestampsShow timestamps in log output-

Example:

dir2msgstr --auto

Or manually:

dir2msgstr -s ./french -o ./french.po --ext msg --overwrite

msgmerge-female

Updates PO files from a POT template using GNU gettext's msgmerge, with special handling to keep female translations. Requires Gettext tools in PATH.

msgmerge-female [PO POT] [-v] [-q] [-t]
ArgumentDescriptionDefault
POPO file to update-
POTPOT template file-
-v, --verboseEnable verbose output-
-q, --quietSuppress info messages-
-t, --timestampsShow timestamps in log output-

Single file:

msgmerge-female french.po english.pot

Batch (uses .bgforge.yml config):

msgmerge-female

resave-po

Resaves a PO file using the polib API to correct formatting. Useful for normalizing PO file structure.

resave-po INPUT_FILE [-v] [-q] [-t]
ArgumentDescriptionDefault
INPUT_FILEPO file to resave-
-v, --verboseEnable verbose output-
-q, --quietSuppress info messages-
-t, --timestampsShow timestamps in log output-

Example:

resave-po ./french.po

lowercase

Recursively renames files and directories to lowercase. Useful for preparing case-insensitive file systems.

lowercase DIR [-v] [-q] [-t]
ArgumentDescriptionDefault
DIRDirectory to process-
-v, --verboseEnable verbose output-
-q, --quietSuppress info messages-
-t, --timestampsShow timestamps in log output-

Example:

lowercase ./french

Note: Excludes .git, .svn, .hg, .github directories, .po files, and README.md.


unfuzzy

Removes fuzzy flags from PO entries where the previous msgid matches the current msgid after applying string replacements. Used to reduce diff noise after source language spelling changes.

Create unfuzzy.yml with replacements:

- ["Nuka Cola", "Nuka-Cola"]
- ["nuka cola", "Nuka-Cola"]
unfuzzy INPUT_FILE [-w] [-v] [-q] [-t]
ArgumentDescriptionDefault
INPUT_FILEPO file to process-
-wWrite changes to file (without this, previews only)-
-v, --verboseEnable verbose output-
-q, --quietSuppress info messages-
-t, --timestampsShow timestamps in log output-

Example:

unfuzzy ./french.po -w

bgforge-config

Reads values from .bgforge.yml configuration. Primarily used by GitHub Actions.

bgforge-config STANZA KEY
ArgumentDescription
STANZAConfig section (e.g., translation)
KEYConfig key (e.g., encoding)

Example:

bgforge-config translation encoding

GitHub Action

A GitHub Action is available for automatic processing. See docs/action.md for details.

About

A set of helper tools to convert Fallout 1/2 MSG and WeiDU TRA into GNU gettext PO and back

Topics

Resources

Stars

4 stars

Watchers

2 watching

Forks

Releases

Sponsor this project

Packages

Used by

Contributors

Languages