Skip to content

Instantly share code, notes, and snippets.

@aruseni
Created December 15, 2012 19:34
Show Gist options
  • Save aruseni/4298465 to your computer and use it in GitHub Desktop.
Save aruseni/4298465 to your computer and use it in GitHub Desktop.
These strings are not present in any other template or Python file, so you just put them here in order to make the makemessages management command keep them in the translation file.
{% load i18n %}
{% trans "Some string you want to keep in the django.po translation file" %}
{% trans "So makemessages won't comment it out each time you run it" %}
{% trans "This template does not have to be used anywhere, putting it in your templates directory is enough" %}
@aruseni
Copy link
Author

aruseni commented Dec 15, 2012

Sometimes you want to put some dynamically generated strings in the translation file, but do not want to manually uncomment these messages after each run of the makemessages management command (python manage.py makemessages). In these cases you can put such template in your templates dir and add the strings there (so they won't be automatically commented out when you run the makemessages management command).

Please note that if you deal with translation of model objects content, you can also use django-modeltranslation or some other similar package.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment