Windows: Implement GetPreferredLanguages for UWP and support l18n (flutter/engine#27311)

This commit is contained in:
moko256 2021-07-24 08:41:57 +09:00 committed by GitHub
parent b14a9f832b
commit bd9583cd04
2 changed files with 9 additions and 6 deletions

View File

@ -19,3 +19,4 @@ SOTEC GmbH & Co. KG <sotec-contributors@sotec.eu>
Hidenori Matsubayashi <Hidenori.Matsubayashi@sony.com>
Sarbagya Dhaubanjar <mail@sarbagyastha.com.np>
Callum Moffat <callum@moffatman.com>
Koutaro Mori <koutaro.mo@gmail.com>

View File

@ -8,6 +8,9 @@
#include <sstream>
#include "third_party/cppwinrt/generated/winrt/Windows.Foundation.Collections.h"
#include "third_party/cppwinrt/generated/winrt/Windows.System.UserProfile.h"
#include "flutter/shell/platform/windows/string_conversion.h"
namespace flutter {
@ -23,12 +26,11 @@ std::vector<LanguageInfo> GetPreferredLanguageInfo() {
std::vector<std::wstring> GetPreferredLanguages() {
std::vector<std::wstring> languages;
// TODO(clarkezone) need to implement a complete version of this function in
// order to get full list of platform languages
// https://github.com/flutter/flutter/issues/74156
languages.push_back(L"en-US");
languages.push_back(L"en");
auto platform_langueages = winrt::Windows::System::UserProfile::
GlobalizationPreferences::Languages();
for (const auto& platform_language : platform_langueages) {
languages.push_back(std::wstring{platform_language});
}
return languages;
}