Unicode TR 35: add likely subtags in the specified order

The Likely Subtags section (4.3) of Unicode TR 35 stipulates a quite
specific order for trying the various candidate lookups; we had two of
them swapped and were missing the last.

Change-Id: Idcd8e7f7c9849be3ee805245e7746435e992c1db
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
This commit is contained in:
Edward Welbourne 2017-12-04 16:09:42 +01:00
parent b0726e8641
commit 8c80dad4b5

View File

@ -233,14 +233,6 @@ QLocaleId QLocaleId::withLikelySubtagsAdded() const
if (addLikelySubtags(id))
return id;
}
// language_script
if (country_id) {
QLocaleId id = QLocaleId::fromIds(language_id, script_id, 0);
if (addLikelySubtags(id)) {
id.country_id = country_id;
return id;
}
}
// language_region
if (script_id) {
QLocaleId id = QLocaleId::fromIds(language_id, 0, country_id);
@ -249,6 +241,14 @@ QLocaleId QLocaleId::withLikelySubtagsAdded() const
return id;
}
}
// language_script
if (country_id) {
QLocaleId id = QLocaleId::fromIds(language_id, script_id, 0);
if (addLikelySubtags(id)) {
id.country_id = country_id;
return id;
}
}
// language
if (script_id && country_id) {
QLocaleId id = QLocaleId::fromIds(language_id, 0, 0);
@ -258,6 +258,14 @@ QLocaleId QLocaleId::withLikelySubtagsAdded() const
return id;
}
}
// und_script
if (language_id) {
QLocaleId id = QLocaleId::fromIds(0, script_id, 0);
if (addLikelySubtags(id)) {
id.language_id = language_id;
return id;
}
}
return *this;
}