View Source Gettext Pseudolocalize

A Mix task for pseudolocalizing Gettext translations in Elixir applications. Pseudolocalization is a software testing method used to verify internationalization aspects of software by replacing ordinary characters with accented or modified versions while maintaining readability.

Features

  • Preserves Gettext interpolation variables (e.g., %{name})
  • Converts ASCII characters to accented Unicode equivalents
  • Wraps strings in brackets (⟦...⟧) for easy identification
  • Maintains all PO file headers and metadata
  • Preserves existing translations

Installation

Add gettext_pseudolocalize to your list of dependencies in mix.exs:

def deps do
  [
    {:gettext_pseudolocalize, "~> 0.1.0"}
  ]
end

Usage

  1. First, extract your gettext strings:
mix gettext.extract
  1. Merge them into the xx locale - this is done automatically by the gettext_pseudolocalize task:
mix gettext.merge priv/gettext --locale=xx
  1. Run the pseudolocalization:
mix gettext.pseudolocalize

This will process all .po files in your xx locale directory (priv/gettext/xx/LC_MESSAGES/).

Example

Original string in .pot file:

msgid "Hello %{name}"
msgstr ""

After pseudolocalization in xx locale:

msgid "Hello %{name}"
msgstr "⟦Ȟêĺĺø %{name}~~~~~~⟧"

Benefits

Pseudolocalization helps identify:

  • Hardcoded strings that should be localized
  • Character encoding issues
  • UI issues with different character lengths
  • String concatenation issues
  • Unicode/font support problems

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b feature/my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin feature/my-new-feature)
  5. Create new Pull Request

License

This project is licensed under the Apache-2.0 License.