[locale] Prefer non-empty country matches

Prefer "en_US" over "en" even when asking for "en".
This commit is contained in:
Adriaan de Groot 2022-08-23 02:02:24 +02:00
parent a422fd80d9
commit 3540121449

View File

@ -84,7 +84,7 @@ LocaleNameParts::similarity( const LocaleNameParts& other ) const
return 0;
}
const auto matched_region = ( region == other.region ? 30 : 0 );
const auto matched_country = ( country == other.country ? 20 : 0 );
const auto matched_country = ( country == other.country ? ( country.isEmpty() ? 10 : 20 ) : 0 );
const auto no_other_country_given = ( ( country != other.country && other.country.isEmpty() ) ? 10 : 0 );
return 50 + matched_region + matched_country + no_other_country_given;
}