Commit 981b0bad authored by Volker Krause's avatar Volker Krause
Browse files

When falling back to any translation, check it's actually a translation

Some tags accessed with localization might actually use other sub-
qualifiers instead or alongside the translations, so do some basic
check whether we are looking at a plausible language id.
parent da518c6a
......@@ -413,7 +413,10 @@ inline QByteArray tagValue(const Elem& elem, const char *keyName, const QLocale
// check if there is at least one in any language we can use
key.resize(baseLen);
const auto it = std::find_if(elem.tags.begin(), elem.tags.end(), [key, baseLen](const auto &tag) { return std::strncmp(tag.key.name(), key.constData(), baseLen) == 0; });
const auto it = std::find_if(elem.tags.begin(), elem.tags.end(), [key, baseLen](const auto &tag) {
return std::strncmp(tag.key.name(), key.constData(), baseLen) == 0
&& std::strlen(tag.key.name()) == key.size() + 2; // primitive check whether this is a plausible language rather than some other qualifier
});
if (it != elem.tags.end()) {
return (*it).value;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment