FakeLion rides the PyPI

Put a bit more work into FakeLion (L10N, get it) this afternoon to see how a particular project is doing on getting i18n coverage.  I added some quick flags so you can suppress HTML-code escaping, suppress Python string-subs escaping, disable the reversing of strings, and use full-width-latin substitution characters (which does a pretty good job of simulating the expansion that often happens when going to more verbose languages IMO).  There's also now a setup script.

You can test a django site (what I'm testing) like so (assuming you've done some i18n):

easy_install polib fakelion
cd path/to/app
mkdir locale
django-admin.py makemessages -l fr
python -m fakelion -f locale/fr/LC_MESSAGES/django.po
django-admin.py compilemessages

Which builds the fake-localized French language catalog for your site.  Now, add django.middleware.locale.LocaleMiddleware to your site's middleware, and set

('en', _('English')),
('fr', _('French')),

In your settings.py and restart your Django server.  Your site should appear unchanged when you visit it with English as your preferred language, but if you change your browser's preference to French you should see your marked-for-translation text show up as reversed full-width version of the marked up text.  You can then see which parts of your interface are not yet marked for i18n/l10n and can fix them accordingly.

Itch scratched.


  1. David Fraser

    David Fraser on 08/22/2011 1:31 a.m. #

    Great you're building this up. Really like the name!

    I have some equivalent infrastructure but in a non-Django project with its own localization framework (but still using gettext) so I'm wondering if there's some overlap. You can see the code at:
    This uses babel to run the translation process. Some example fake locales are located here:

    Some differences:
    - I uses script codes to represent the faux locales (en_Cyrl rather than en), so that in a user interface language selector you can still select real English, but the fake locales can always be present
    - A different system for handling escapes

Comments are closed.


Pingbacks are closed.