Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6814999
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T20:45:18+00:00 2026-05-26T20:45:18+00:00

Django documentation states: The caveat with using variables or computed values, as in the

  • 0

Django documentation states:

The caveat with using variables or computed values, as in the previous
two examples, is that Django’s translation-string-detecting utility,
django-admin.py makemessages, won’t be able to find these strings.

That is fine with me, I’m ready to provide translations for all possible values of the translated variable by hand. But how to do that?

Let’s say I have in my template code like this:

{% trans var %}

The var is extracted from the database, and I know all of the possible values of it – let’s say the possible values are “Alice” and “Bob”.

I thought all I need to do is provide entries like these:

msgid "Alice"
msgstr "Alicja"

in django.po file. Unfortunately, whenever i run djangoadmin makemessages after that, these entries are being commented out:

#~ msgid "Alice"
#~ msgstr "Alicja"

What am I doing wrong? Have I misunderstood the idea of translating computed values?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-26T20:45:18+00:00Added an answer on May 26, 2026 at 8:45 pm

    We’re currently in the process of figuring this out as well. While we haven’t done so properly, we do have a rather annoyingly ugly hack to get around it.

    We simply define a “dummy” function somewhere in the code (for example your models.py or even settings.py) and fill it up with all the strings that we need to have a translation for.

    from django.utils.translation import ugettext_lazy as _, pgettext
    
    def dummy_for_makemessages():
        """
        This function allows manage makemessages to find the forecast types for translation.
        Removing this code causes makemessages to comment out those PO entries, so don't do that
        unless you find a better way to do this
        """
        pgettext('forecast type', 'some string')
        pgettext('forecast type', 'some other string')
        pgettext('forecast type', 'yet another string')
        pgettext('forecast type', 'etc')
        pgettext('forecast type', 'etc again')
        pgettext('forecast type', 'and again and again')
    

    This function is never called but simply defining it prevents the message strings from getting commented out by makemessages.

    Not the most elegant solution but it works.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Django's views documentation states that the default 500 view passes no variables to this
The Django documentation on its CSRF protection states that: In addition, for HTTPS requests,
I am having problems using django-tagging . I try to follow the documentation but
I'm totally new to django, and I'm using its documentation to get help on
The Django 1.4 documentation on tests states: For a given Django application, the test
The documentation states that there is a command-line shell for sqlite3: To start the
I'm using Google App Engine and Django templates. I have a table that I
The Django documentation ( http://docs.djangoproject.com/en/1.3/topics/testing/#running-tests ) says that you can run individual test cases
The Django documentation states the following clearly: Not every template in contrib\admin\templates\admin may be
I noticed in the django documentation that when DEBUG is False it will mail

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.