Question

I got a line for a Qlabel like this:

QString(tr("Are you sure you want to delete the scene called %1 ?")).arg(variable);

Some people told me you can't translate that. They told me to append different strings with the parameters and the text...

But what about a phrase using various parameters? How does the translator know which order if it is appended in that order?.

Has no sense for me. There must be a way!.

Was it helpful?

Solution

Should should drop the QString(...) part, since tr() already returns a QString. Otherwise I don't see a problem with the translation of the following code:

tr("Are you sure you want to delete the scene called %1 ?").arg(variable);

In the Use QString::arg() for Dynamic Text part of the Qt documentation you can find more information.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top