[Development] format-like tr()

Edward Welbourne edward.welbourne at qt.io
Thu Oct 24 19:04:50 CEST 2024


Giuseppe D'Angelo (24 October 2024 18:54) wrote:
> I'm actually thinking that we may be missing a use case: tr() can be
> called with a string that does NOT contain %n. In this case, the
> quantity parameter is only used to look up which plural form to
> translate to; the developer can then use e.g. arg() replacements, and
> with those, manage localization, precision and what not:
>
> tr("You bought a total of %L1 apple(s)", n).arg(n) // localized and pluralized
>
> We likely need to find a way to support this as well?

Given that that does also substitute the relevant number into the
string, I offer:

  tr("The apple(s) you bought cost %L1", n).arg(price);

where the number controlling the singular/plural choice isn't inserted
into the result, but something else is.

	Eddy.


More information about the Development mailing list