PDA

View Full Version : Multiple plurals in the same string?



PaladinKnight
27th May 2012, 01:50
Hi!

What is the best way to deal with multiple plurals on the same line?

i.e. Something like

"There are %n dollar(s) and %n cent(s)."

(This wouldn't actually work...)

The only thing I could think of is handling each of them separately and then inserting them back in the original string using either QString.arg() or QString.replace().

i.e. with QString.arg it would look something like this

"There are %1 and %2"

where %1 would be replaced with tr("%n dollar(s)", "", nb_dollars) and %2 would be replaced with tr("%n cent(s)", "", nb_cents).

Is there a better way to handle this?

Thank you!

Nick