[MRTCore] Sync between WGA.PrimaryLanguageOverride and MWGA.PrimaryLanguageOverride

This commit is contained in:
Stefan Markovic 2024-07-30 09:51:45 +02:00
Родитель f753170ead
Коммит aaa39d5e70
1 изменённых файлов: 12 добавлений и 0 удалений

Просмотреть файл

@ -6,6 +6,8 @@
#include "ResourceContext.g.cpp"
#include "winrt/Windows.Globalization.h"
#include <AppModel.Identity.h>
const wchar_t c_languageQualifierName[] = L"Language";
#include "ApplicationLanguages.h"
@ -101,6 +103,16 @@ void ResourceContext::Apply()
winrt::check_hresult(MrmSetQualifier(m_resourceContext, eachValue.Key().c_str(), eachValue.Value().c_str()));
}
}
// sync with Windows::Globalization::ApplicationLanguages::PrimaryLanguageOverride if it has been updated more recently
if (AppModel::Identity::IsPackagedProcess())
{
auto language = winrt::Windows::Globalization::ApplicationLanguages::PrimaryLanguageOverride();
if (language != ApplicationLanguages::PrimaryLanguageOverride())
{
ApplicationLanguages::PrimaryLanguageOverride(language);
}
}
if (!ApplicationLanguages::PrimaryLanguageOverride().empty())
{
winrt::check_hresult(MrmSetQualifier(m_resourceContext, c_languageQualifierName, ApplicationLanguages::PrimaryLanguageOverride().c_str()));