[Development] [Interest] Direct-lookup translation, even for English (was Re: get english translation)
Thiago Macieira
thiago.macieira at intel.com
Thu Sep 4 20:59:05 CEST 2014
On Thursday 04 September 2014 20:31:49 Andre Somers wrote:
> That sounds rather short-sighted to me.
> It means that an inconsistency is introduced for no good reason at all.
> If you want to have something that works for English only, it would be
> rather trivial to write a free function like this:
>
> QString singularOrPlural(QString singular, QString plural, int value) {
> if (value == 0 || qAbs(value) > 1) {
> return plural;
> }
> return singular;
> }
>
> There you go, there's your special tr version.
This did not extract the string for translation. It needs to be something that
does extract for translation and does translate to another language if a
translator was loaded.
> >> ..or alternatively we need to be clarify our documentation to explicitly
> >> mention that this plural-form-translation feature requires a translation
> >> to
> >> be installed, even in English.
> >
> > Which is what I don't want. This basically requires everyone to always
> > load
> > the Qt translation, even if their apps aren't l10n'ed.
>
> So? If they forget, they'll end up with "1 file(s) found" instead of "1
> file found" or "2 files found". Big deal.
So long as we actually write using the (s) plural. Which we sometimes don't:
In designer:
buddyeditor.cpp: undoStack()->beginMacro(tr("Remove %n buddies", 0,
selectedConnections.size()));
buddyeditor.cpp: undoStack()->beginMacro(tr("Add %n buddies", 0, count));
qdesigner_propertycommand.cpp:
setText(QCoreApplication::translate("Command", "Changed '%1' of %n objects",
"", count).arg(propertyName()));
Source code bugs? Probably.
> A quick search for %n in the Qt .ts files would reveal that. I don't
> have them here, or I would take a peek.
> But even so: Qt could pre-load the Qt .qm file by default from an
> internal resource, and I guess that makes sense. There is no need for a
> special tr() version to do that.
Right, those are the two alternatives: preload a .qm or not require a .qm.
--
Thiago Macieira - thiago.macieira (AT) intel.com
Software Architect - Intel Open Source Technology Center
More information about the Development
mailing list