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 8743605
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:42:30+00:00 2026-06-13T11:42:30+00:00

In our code, we have the word Photo marked for translation in singular. At

  • 0

In our code, we have the word “Photo” marked for translation in singular. At a different position in the code, we have this word in pluralized translation “Photo” / “Photos”, liek so:

1 {% trans 'Photo' %}
2 {% trans 'Photos' %}

and

{{ x }} {% blocktrans count counter=x %}Photo{% plural %}Photos{% endblocktrans %}

Possibly, we must use our counter variable x inside the translation strings. However, I couldn’t find anything about such requirement in the docs. Anyway, with our code, all we get in our PO files is:

msgid "Photos"
msgstr ""

msgid "Photo"
msgid_plural "Photos"
msgstr[0] ""
msgstr[1] ""

There is no msgid for “Photo”, resulting in “Photo” not being translated at all, since the actual translation string does not exist – except when used in *n*gettext, but not in {% trans ‘Photo’ %}.

Am I doing something wrong here? Is it a Django bug?

  • 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-06-13T11:42:31+00:00Added an answer on June 13, 2026 at 11:42 am

    It’s not a bug in Django — you are trying to translate the term “Photo” two different ways, in two different places. Once as a plain (number-agnostic) term, and once as a number-aware term. There is no way to represent that in a PO file, which can only have one entry with msgid “Photo”.

    (Note that “Photos” is handled differently in your case, since as far as gettext is concerned, it is only translated once, as a plain term.)

    Plural forms can be very different across languages, and you shouldn’t just be trying to localize the single noun “Photo” in this case. Instead, you should be localizing the term “x Photo(s)” for the singular and plural case in each language.

    (In English, that would be “1 Photo” and “{x} Photos”, but in other languages, you could have more or less than two, and the number itself may not even go before the word for “photos”, which is why you have to localize the whole term)

    In your template, then, you should have:

    {% blocktrans count counter=x %}{{ count }} Photo{% plural %}{{ count }} Photos{% endblocktrans %}
    

    Then your PO file should contain lines like this:

    msgid "%(count)s Photo"
    msgid_plural "%(count)s Photos"
    msgstr[0] ""
    msgstr[1] ""
    

    And you can localize msgstr[0] (singular case) and msgstr[1] (plural case) for each language. Some languages will require more than just [0] and [1], but gettext should take care of that for you when it generates the PO file for that language.

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

Sidebar

Related Questions

I have code like this which opens Word documents for editing from our intranet,
In our code we have quite a few cases of this pattern: class outerClass
We have this anonymous function in our code, which is part of the jQuery's
In many places in our application we have code like this: using(RAPI rapi =
In our code I have the following, for now please ignore the //* bits;
We have recently started using FxCop on our code base and I am in
I have introduced boost to our code base, on my machine I created a
How much of an impact will migrating to Flex 4 have on our code
Ok, We have a lot of where clauses in our code. We have just
Our website code is written in PHP. We have very little testing in regards

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.