Q:

Is it safe to check if a string equals to a qsTr string in a multi language app - qml

So what if I have a the following property:
property string someString: qsTr("Text")
and I have the following function:
function isEqual(toThisString) {
  if (someString === toThisString) {
    return true
  } else 
    return false
  }
}

My question is what if my application has a translation to some other language other than English. Will the function still compare to "Text" or will it compare to the translated string?

A:

An example with Qt:
const QString english = "Hello world");
const QString spanish = QObject::tr(english); // Hola mundo

Is equal?
qDebug() << "Is equal? " << (english == spanish); 
qDebug() << "Is equal? " << (QObject::tr(english) == spanish);

Result:
Is equal? false
Is equal? true

You have to translate every string, and should be the same string exactly. It's dificult to manage, looks like a recipe for disaster.
You have to use an alternative data field to compare values, avoid strings. Example for a QCombobox:
enum Countries {EEUU = 0, Spain, France};
QCombobox* combo = new QCombobox;
combo->addItem(QObject::tr("EEUU"), EEUU);
combo->addItem(QObject::tr("Spain"), Spain);
combo->addItem(QObject::tr("France"), France);

To get the selected country or compare with a field in the combo model, you could use currentData() function or something like this.

