Skip to content

Instantly share code, notes, and snippets.

@cstrap
Created November 24, 2015 10:30
Show Gist options
  • Select an option

  • Save cstrap/2c4e5b03c0dfe3621571 to your computer and use it in GitHub Desktop.

Select an option

Save cstrap/2c4e5b03c0dfe3621571 to your computer and use it in GitHub Desktop.
A way to generate localization files :: Python
# Creating Template
$ find . -iname "*.py" -exec xgettext -o messages.pot {} \;
# Copy template message.pot into locale/XX/LC_MESSAGES
# For example (this is a typical django app tree structure)
...
│   ├── locale
│   │   ├── en
│   │   │   └── LC_MESSAGES
│   │   │   ├── django.mo
│   │   │   └── django.po
│   │   └── it
│   │   └── LC_MESSAGES
│   │   ├── django.mo
│   │   └── django.po
$ cp message.pot locale/en/LCMESSAGES/django.po
# Edit the django.po file with an editor
$ vi django.mo
# Compiling .mo file
$ msgfmt -o django.mo django.po
# Resources
# https://pymotw.com/2/gettext/
# http://stackoverflow.com/questions/739314/easiest-way-to-generate-localization-files
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment