2

In my project there's a sentence need to be translated. Here it is:

We provide {{book_count}} book(s), {{game_account}} game(s) and {{album_account}} music album(s) for you.

We need to handle the singular and plural form for it, and it has 3 counters here. I find it's not easy to use django i18n tag for it.

For now I extract the phrases out as model values, handle them one by one first, then pass to the sentence. Like this:

{%blocktrans with books=book_text games=game_text albums=album_text %}We provide {{books}}, {{games}} and {{albums}} for you.{%endblocktrans%}

This seems no good for me. Maybe there's a better way to deal with this, or blockstrans can have some kind of nested syntax?

Simeon Visser
  • 118,920
  • 18
  • 185
  • 180
Chris Li
  • 3,715
  • 3
  • 29
  • 31

1 Answers1

0

You could use pluralize filter to convert text to its plural form based on some variable.

Arpit
  • 953
  • 7
  • 11