Pytigon's internationalization (I18N) system builds on Django's proven translation framework, adding automatic translation discovery, menu item localization, and JavaScript-side translation support.
Pytigon integrates with Django's gettext-based translation system:
_() or pgettext(){% translate %} or _("text").po files with make_i18n command.po files using any PO editor.mo — Django loads these at runtimefrom django.utils.translation import gettext as _
class Album(models.Model):
name = models.CharField(_("Name"), max_length=128)
artist = models.CharField(_("Artist"), max_length=128)
class Meta:
verbose_name = _("Album")
verbose_name_plural = _("Albums")
In .ihtml templates:
[translate "Welcome to Pytigon"]
[blocktranslate with name=user.username]
Hello, {{ name }}!
Pytigon automatically scans for translatable strings in:
python manage.py make_i18n
This command:
1. Scans all Python files for _() calls
2. Scans all .ihtml templates for {% translate %} tags
3. Generates .po files in locale/[lang]/LC_MESSAGES/
4. Updates existing .po files with new strings (preserving existing translations)
Pytigon provides client-side translation support through the frontend library:
// JavaScript
ptig.i18n.gettext("Save");
ptig.i18n.pgettext("Button label", "Save");
The JavaScript translation catalog is served automatically and cached in the browser.
Menu items defined in the developer tools are automatically localized. The "Name" field is converted to a translation key by lowercasing and replacing spaces with underscores. Translation files contain entries like:
msgid "user_management"
msgstr "Benutzerverwaltung"
Pytigon detects the user's language from:
1. URL prefix (/en/, /de/, /pl/)
2. User's browser Accept-Language header
3. User profile setting (if the user is logged in)
4. Default language from settings_app.py
Configure available languages in settings:
LANGUAGES = [
('en', 'English'),
('pl', 'Polski'),
('de', 'Deutsch'),
]