[Development] format-like tr()
Thiago Macieira
thiago.macieira at intel.com
Thu Oct 24 19:27:58 CEST 2024
On Thursday 24 October 2024 09:54:43 Pacific Daylight Time Giuseppe D'Angelo
via Development wrote:
> > This is what I'm more worried about: telling the string-extraction tools
> > that don't really understand C++ that this is a string with plurals. I
> > don't know if they need to: is it acceptable for the translator to simply
> > supply 2-5 different forms? Or does the tooling -- and this is both
> > .ts/.qm and .po/.mo files -- need to know that multiple forms are
> > possible? Will Linguist allow the translator to enter 2-5 different
> > translations?
>
>
> Maybe I'm missing something, but the tooling does all of this already:
> lupdate extracts all the strings in tr() calls, and linguist allows me
> to add several translated forms, depending on the target language (for
> Italian: singular/plural; for Polish: singular, paucal, plural...).
>
> What do we need to change here exactly?
Maybe nothing, but I don't know. That's why I am asking.
Does the tooling allow entering multiple translated variants for *any*
translatable string? Or does it need to know that the original has a plural
form?
> 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:
I don't think this should be allowed. The number of replacement fields in the
string and the number of parameters passed to trFormat() must match.
> > 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?
trFormat("You bought a total of {:Ln} apple(s)", Qt::Cardinality(n));
--
Thiago Macieira - thiago.macieira (AT) intel.com
Principal Engineer - Intel DCAI Platform & System Engineering
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 5152 bytes
Desc: not available
URL: <http://lists.qt-project.org/pipermail/development/attachments/20241024/d86efa49/attachment-0001.bin>
More information about the Development
mailing list