浏览代码

UI: Fix GetPreferredLocales locale detection

When scanning the preferred locales, always pick the one
with exact match before falling back to other matches.
Ka Ho Ng 5 年之前
父节点
当前提交
33dd7eebd2
共有 1 个文件被更改,包括 3 次插入2 次删除
  1. 3 2
      UI/platform-x11.cpp

+ 3 - 2
UI/platform-x11.cpp

@@ -72,6 +72,7 @@ string GetDefaultVideoSavePath()
 vector<string> GetPreferredLocales()
 vector<string> GetPreferredLocales()
 {
 {
 	setlocale(LC_ALL, "");
 	setlocale(LC_ALL, "");
+	vector<string> matched;
 	string messages = setlocale(LC_MESSAGES, NULL);
 	string messages = setlocale(LC_MESSAGES, NULL);
 	if (!messages.size() || messages == "C" || messages == "POSIX")
 	if (!messages.size() || messages == "C" || messages == "POSIX")
 		return {};
 		return {};
@@ -85,10 +86,10 @@ vector<string> GetPreferredLocales()
 			return {locale};
 			return {locale};
 
 
 		if (locale.substr(0, 2) == messages.substr(0, 2))
 		if (locale.substr(0, 2) == messages.substr(0, 2))
-			return {locale};
+			matched.push_back(locale);
 	}
 	}
 
 
-	return {};
+	return matched;
 }
 }
 
 
 bool IsAlwaysOnTop(QWidget *window)
 bool IsAlwaysOnTop(QWidget *window)