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"}
]
endUsage
- First, extract your gettext strings:
mix gettext.extract
- Merge them into the xx locale:
mix gettext.merge priv/gettext --locale=xx
- 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
- Fork it
- Create your feature branch (
git checkout -b feature/my-new-feature) - Commit your changes (
git commit -am 'Add some feature') - Push to the branch (
git push origin feature/my-new-feature) - Create new Pull Request
License
This project is licensed under the MIT License.