A
A
Andrei Smirnov2018-08-28 15:49:01
Qt
Andrei Smirnov, 2018-08-28 15:49:01

How to make Qt tr() handle plural without loading translation?

There is such a construction:
tr("%n item(s) replaced", "", count);
Which should produce lines like "1 item replaced", "2 items replaced".
I have an application in English and I do not plan to download other languages.
But these constructions don't work if you don't upload translation files.
What if I'm not going to download them?
How else can I tell Qt that my application is in English? Besides

QLocale::setDefault(QLocale(QLocale::English, QLocale::UnitedStates));

UPD:
I found out that even if you load some default translation, in which all translations are simply marked as completed and the required language and country are set, magic does not happen ... so if you explicitly make a translation in a linguist, then it works.
I honestly thought that QTranslator itself will look into these brackets "(s)" and either remove or add "s" itself.
Thank you!

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question