Вопрос

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!.

Это было полезно?

Решение

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.

Лицензировано под: CC-BY-SA с атрибуция
Не связан с StackOverflow
scroll top