diff --git a/BuildAll.ps1 b/BuildAll.ps1
index 5d99bb1055..23b0fbd30a 100644
--- a/BuildAll.ps1
+++ b/BuildAll.ps1
@@ -332,6 +332,7 @@ Try {
Copy-Item -path "BuildOutput\$configurationForMrtAndAnyCPU\$platformToRun\Microsoft.Windows.ApplicationModel.Resources.Projection\Microsoft.Windows.ApplicationModel.Resources.Projection.dll" -destination "$BasePath\lib\net6.0-windows10.0.17763.0" -force
Copy-Item -path "BuildOutput\$configurationForMrtAndAnyCPU\$platformToRun\Microsoft.Windows.ApplicationModel.Resources.Projection\Microsoft.Windows.ApplicationModel.Resources.Projection.pdb" -destination "$BasePath\lib\net6.0-windows10.0.17763.0" -force
Copy-Item -path "BuildOutput\$configurationForMrtAndAnyCPU\$platformToRun\Microsoft.Windows.ApplicationModel.Resources\Microsoft.Windows.ApplicationModel.Resources.winmd" -destination "$BasePath\lib\uap10.0" -force
+ Copy-Item -path "BuildOutput\$configurationForMrtAndAnyCPU\$platformToRun\Microsoft.Windows.ApplicationModel.Resources\Microsoft.Windows.Globalization.winmd" -destination "$BasePath\lib\uap10.0" -force
}
}
diff --git a/build/NuSpecs/AppxManifest.xml b/build/NuSpecs/AppxManifest.xml
index e08876e201..d715353b56 100644
--- a/build/NuSpecs/AppxManifest.xml
+++ b/build/NuSpecs/AppxManifest.xml
@@ -22,6 +22,7 @@
+
diff --git a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/projection/Microsoft.Windows.ApplicationModel.Resources.Projection.csproj b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/projection/Microsoft.Windows.ApplicationModel.Resources.Projection.csproj
index 1630e110f5..65a0c7a109 100644
--- a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/projection/Microsoft.Windows.ApplicationModel.Resources.Projection.csproj
+++ b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/projection/Microsoft.Windows.ApplicationModel.Resources.Projection.csproj
@@ -1,4 +1,4 @@
-
+
net6.0-windows10.0.17763.0
10.0.17763.0
@@ -21,7 +21,7 @@
- Microsoft.Windows.ApplicationModel.Resources
+ Microsoft.Windows.Globalization;Microsoft.Windows.ApplicationModel.Resources
10.0.17763.0
MSB3271
@@ -30,10 +30,11 @@
pdbonly
true
-
+
+
diff --git a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ApplicationLanguages.cpp b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ApplicationLanguages.cpp
new file mode 100644
index 0000000000..892a3ab55a
--- /dev/null
+++ b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ApplicationLanguages.cpp
@@ -0,0 +1,56 @@
+// Copyright (c) Microsoft Corporation and Contributors.
+// Licensed under the MIT License.
+
+#include "pch.h"
+#include "ApplicationLanguages.h"
+#include "Microsoft.Windows.Globalization.ApplicationLanguages.g.cpp"
+
+#include
+#include
+
+#include
+
+namespace winrt::Microsoft::Windows::Globalization::implementation
+{
+ hstring ApplicationLanguages::m_language;
+ wil::srwlock ApplicationLanguages::m_lock;
+
+
+ winrt::Windows::Foundation::Collections::IVectorView ApplicationLanguages::Languages()
+ {
+ return winrt::Windows::Globalization::ApplicationLanguages::Languages();
+ }
+
+ winrt::Windows::Foundation::Collections::IVectorView ApplicationLanguages::ManifestLanguages()
+ {
+ if (AppModel::Identity::IsPackagedProcess())
+ {
+ return winrt::Windows::Globalization::ApplicationLanguages::ManifestLanguages();
+ }
+ else
+ {
+ return {};
+ }
+ }
+
+ hstring ApplicationLanguages::PrimaryLanguageOverride()
+ {
+ auto criticalSection{ m_lock.lock_shared() };
+ return m_language;
+ }
+
+ void ApplicationLanguages::PrimaryLanguageOverride(hstring const& language)
+ {
+ bool isValidLanguageTag = IsWellFormedTag(language.c_str());
+
+ THROW_HR_IF_MSG(E_INVALIDARG, !isValidLanguageTag, "The parameter is incorrect");
+
+ auto criticalSection {m_lock.lock_exclusive()};
+ m_language = language;
+
+ if (AppModel::Identity::IsPackagedProcess())
+ {
+ winrt::Windows::Globalization::ApplicationLanguages::PrimaryLanguageOverride(language);
+ }
+ }
+} // namespace winrt::Microsoft::Windows::Globalization::implementation
diff --git a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ApplicationLanguages.h b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ApplicationLanguages.h
new file mode 100644
index 0000000000..a7ebba9b0c
--- /dev/null
+++ b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ApplicationLanguages.h
@@ -0,0 +1,29 @@
+// Copyright (c) Microsoft Corporation and Contributors.
+// Licensed under the MIT License.
+
+#pragma once
+#include "Microsoft.Windows.Globalization.ApplicationLanguages.g.h"
+
+namespace winrt::Microsoft::Windows::Globalization::implementation
+{
+ struct ApplicationLanguages
+ {
+ ApplicationLanguages() = delete;
+
+ static winrt::Windows::Foundation::Collections::IVectorView Languages();
+ static winrt::Windows::Foundation::Collections::IVectorView ManifestLanguages();
+ static hstring PrimaryLanguageOverride();
+ static void PrimaryLanguageOverride(hstring const& language);
+
+ private:
+ static hstring m_language;
+ static wil::srwlock m_lock;
+ };
+} // namespace winrt::Microsoft::Windows::Globalization::implementation
+
+namespace winrt::Microsoft::Windows::Globalization::factory_implementation
+{
+ struct ApplicationLanguages : ApplicationLanguagesT
+ {
+ };
+} // namespace winrt::Microsoft::Windows::Globalization::factory_implementation
diff --git a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.idl b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.idl
index 3c78578a64..ce3debc026 100644
--- a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.idl
+++ b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.idl
@@ -114,3 +114,18 @@ namespace Microsoft.Windows.ApplicationModel.Resources
static String Theme { get; };
}
} // namespace Microsoft.Windows.ApplicationModel.Resources
+
+namespace Microsoft.Windows.Globalization
+{
+ [contractversion(1)]
+ apicontract MrtCoreContract{};
+
+ [contract(MrtCoreContract, 2)]
+ runtimeclass ApplicationLanguages
+ {
+ static IVectorView Languages { get; };
+ static IVectorView ManifestLanguages { get; };
+ static String PrimaryLanguageOverride;
+ }
+
+} // namespace Microsoft.Windows.Globalization
diff --git a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.vcxproj b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.vcxproj
index d03e31913f..354014afcd 100644
--- a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.vcxproj
+++ b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.vcxproj
@@ -17,7 +17,7 @@
en-US
14.0
Win32Proj
- 10.0.18362.0
+ 10.0.20348.0
10.0.17134.0
@@ -90,12 +90,13 @@
_WINRT_DLL;WIN32_LEAN_AND_MEAN;WINRT_LEAN_AND_MEAN;%(PreprocessorDefinitions)
$(WindowsSDK_WindowsMetadata);$(AdditionalUsingDirectories)
+ $(RepoRoot)\dev\Common;%(AdditionalIncludeDirectories)
Console
false
Microsoft.Windows.ApplicationModel.Resources.def
- $(OutDir)..\mrm\MRM.lib;onecoreuap.lib;%(AdditionalDependencies)
+ $(OutDir)..\mrm\MRM.lib;onecoreuap.lib;bcp47mrm.lib;%(AdditionalDependencies)
@@ -109,6 +110,7 @@
+
@@ -120,6 +122,7 @@
+
@@ -140,7 +143,7 @@
-
+
$(RepoRoot);%(AdditionalIncludeDirectories)
@@ -171,6 +174,7 @@
+
@@ -185,5 +189,6 @@
+
-
+
\ No newline at end of file
diff --git a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.vcxproj.filters b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.vcxproj.filters
index da85707150..2bec9237a6 100644
--- a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.vcxproj.filters
+++ b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/Microsoft.Windows.ApplicationModel.Resources.vcxproj.filters
@@ -29,6 +29,9 @@
Source Files
+
+ Source Files
+
@@ -58,6 +61,9 @@
Header Files
+
+ Header Files
+
@@ -75,4 +81,7 @@
{54696afe-f42a-494a-bc24-3fd0d4192122}
+
+
+
\ No newline at end of file
diff --git a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ResourceContext.cpp b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ResourceContext.cpp
index 88ca9a0b31..73a7e2188b 100644
--- a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ResourceContext.cpp
+++ b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/ResourceContext.cpp
@@ -8,6 +8,10 @@
const wchar_t c_languageQualifierName[] = L"Language";
+#include "ApplicationLanguages.h"
+
+using namespace winrt::Microsoft::Windows::Globalization;
+
namespace winrt::Microsoft::Windows::ApplicationModel::Resources::implementation
{
void ResourceContext::InitializeQualifierNames()
@@ -97,6 +101,10 @@ void ResourceContext::Apply()
winrt::check_hresult(MrmSetQualifier(m_resourceContext, eachValue.Key().c_str(), eachValue.Value().c_str()));
}
}
+ if (!ApplicationLanguages::PrimaryLanguageOverride().empty())
+ {
+ winrt::check_hresult(MrmSetQualifier(m_resourceContext, c_languageQualifierName, ApplicationLanguages::PrimaryLanguageOverride().c_str()));
+ }
}
hstring ResourceContext::GetLangugageContext()
diff --git a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/packages.config b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/packages.config
index 9b45da6a85..28bc519cd2 100644
--- a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/packages.config
+++ b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/packages.config
@@ -4,4 +4,5 @@
-
+
+
\ No newline at end of file
diff --git a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/pch.h b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/pch.h
index 5aae2ce383..d1d419ea2e 100644
--- a/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/pch.h
+++ b/dev/MRTCore/mrt/Microsoft.Windows.ApplicationModel.Resources/src/pch.h
@@ -7,6 +7,9 @@
#include
#include "..\..\core\src\MRM.h"
+#include
+#include
+
struct StringResourceFreer
{
void operator()(wchar_t* resource) { MrmFreeResource(resource); }