Skip to content

Commit 4f83b3c

Browse files
Hong-XiangXiang Hong (from Dev Box)
andauthored
[Fix] Locating Microsoft.WindowsAppRuntime.pri in framework usage (#5582)
* add hot-fix localization try-catch * fixing usage * use wil logger * add get framework path related code * add dll based pri file lookup * code clean * use raii for buffer and proper string length * code clean * use std::array instaed of unique_ptr to C array * simplify by using WIL APIs * remove empty line * using wil library --------- Co-authored-by: Xiang Hong (from Dev Box) <xianghong@microsoft.com>
1 parent 17e256e commit 4f83b3c

File tree

2 files changed

+11
-16
lines changed

2 files changed

+11
-16
lines changed

dev/Interop/StoragePickers/PickerLocalization.cpp

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,22 @@
77

88
#include "pch.h"
99
#include "PickerLocalization.h"
10+
#include <wil/stl.h>
11+
#include <wil/win32_helpers.h>
1012
#include <winrt\base.h>
1113
#include <winrt\Microsoft.Windows.ApplicationModel.Resources.h>
12-
#include <iostream>
1314

1415
namespace PickerLocalization {
15-
const winrt::hstring priPath = L"Microsoft.WindowsAppRuntime.pri";
16+
static PCWSTR c_WindowsAppRuntimeLocalizationPRIFilename{ L"Microsoft.WindowsAppRuntime.pri" };
17+
std::wstring GetPriFilePath()
18+
{
19+
std::filesystem::path modulePath{ wil::GetModuleFileNameW<std::wstring>(wil::GetModuleInstanceHandle()) };
20+
return modulePath.parent_path() / c_WindowsAppRuntimeLocalizationPRIFilename;
21+
}
22+
1623
winrt::hstring GetStoragePickersLocalizationText(winrt::hstring key)
1724
{
25+
static winrt::hstring priPath{ GetPriFilePath() };
1826
auto manager = winrt::Microsoft::Windows::ApplicationModel::Resources::ResourceManager(priPath);
1927
return manager.MainResourceMap().GetValue(key).ValueAsString();
2028
}

dev/Interop/StoragePickers/StoragePickers.vcxitems

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,6 @@
4949
<Midl Include="$(MSBuildThisFileDirectory)Microsoft.Windows.Storage.Pickers.idl" />
5050
</ItemGroup>
5151
<ItemGroup>
52-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\cs-CZ\StoragePickers.resw" />
53-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\de-DE\StoragePickers.resw" />
54-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\en-US\StoragePickers.resw" />
55-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\es-ES\StoragePickers.resw" />
56-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\fr-FR\StoragePickers.resw" />
57-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\it-IT\StoragePickers.resw" />
58-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\ja-JP\StoragePickers.resw" />
59-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\ko-KR\StoragePickers.resw" />
60-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\pl-PL\StoragePickers.resw" />
61-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\pt-BR\StoragePickers.resw" />
62-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\ru-RU\StoragePickers.resw" />
63-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\tr-TR\StoragePickers.resw" />
64-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\zh-CN\StoragePickers.resw" />
65-
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\zh-TW\StoragePickers.resw" />
52+
<PRIResource Include="$(MSBuildThisFileDirectory)Strings\*\*.resw" />
6653
</ItemGroup>
6754
</Project>

0 commit comments

Comments
 (0)