From 35401214499ff6ed98b1dd143883e7b7d4d84130 Mon Sep 17 00:00:00 2001
From: Adriaan de Groot <groot@kde.org>
Date: Tue, 23 Aug 2022 02:02:24 +0200
Subject: [PATCH] [locale] Prefer non-empty country matches

Prefer "en_US" over "en" even when asking for "en".
---
 src/modules/locale/LocaleNames.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/modules/locale/LocaleNames.cpp b/src/modules/locale/LocaleNames.cpp
index 93e8444461..401aa4809f 100644
--- a/src/modules/locale/LocaleNames.cpp
+++ b/src/modules/locale/LocaleNames.cpp
@@ -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;
 }
-- 
GitLab