mix gettext_ops.change_msgid (gettext_ops v0.1.1)

View Source

Update msgid (source text) across all .po and .pot files.

This command updates the msgid field in all translation files while preserving all existing translations (msgstr values remain intact). It's useful for fixing typos, improving wording, or standardizing terminology in your source strings.

Usage

mix gettext_ops.change_msgid OLD_MSGID NEW_MSGID [options]

What It Does

  1. Finds all .po files in priv/gettext/*/LC_MESSAGES/ for the specified domain
  2. Finds the .pot template file for the specified domain
  3. Updates the msgid in all matching entries
  4. Preserves all translations (msgstr values remain intact)
  5. Shows summary of changes

Arguments

  • OLD_MSGID - The current msgid to find and replace
  • NEW_MSGID - The new msgid to use

Options

  • --dry-run - Preview changes without modifying files
  • --domain / -d - Gettext domain (defaults to configured default_domain)

Examples

# Update msgid everywhere
mix gettext_ops.change_msgid "Sign In" "Log In"

# Preview changes first (recommended)
mix gettext_ops.change_msgid --dry-run "Sign In" "Log In"

# Specific domain
mix gettext_ops.change_msgid "Error" "Warning" --domain errors

Dry Run Output Example

Would update the following files:

 priv/gettext/sv/LC_MESSAGES/default.po (1 entry)
  msgid "Sign In"  "Log In"
  msgstr "Logga in" (preserved)

 priv/gettext/en/LC_MESSAGES/default.po (1 entry)
  msgid "Sign In"  "Log In"
  msgstr "" (preserved)

 priv/gettext/default.pot (1 entry)
  msgid "Sign In"  "Log In"

Would update 3 file(s) with 3 total entries

Actual Update Output

Updated the following files:

 priv/gettext/sv/LC_MESSAGES/default.po (1 entry)
 priv/gettext/en/LC_MESSAGES/default.po (1 entry)
 priv/gettext/default.pot (1 entry)

Updated 3 file(s) with 3 total entries

Safety Features

  • Atomic updates: Files are written atomically to prevent corruption
  • Dry run mode: Always preview changes with --dry-run before applying
  • Preserves translations: All msgstr values remain unchanged
  • Preserves metadata: Comments, references, and flags are retained

Important Notes

  • This command does NOT update source code references
  • After changing msgid, you may need to update your source code separately
  • Use --dry-run first to verify which files will be affected
  • All translations (msgstr) are preserved automatically