用于使用托管 C++ 进行本地化的 .resx 文件

.resx files for localization with managed C++

我正在尝试使用 .resx 文件在带有 VS2013 的托管 C++ CLR 项目中进行字符串本地化。在我的项目 Resources Files 文件夹中,我右键单击 > 添加项目 > .resx 文件并将其命名为 AppLocalization.resx。我再做一次并创建 AppLocalization.fr.resx。然后我为每个添加一个具有相同名称的不同字符串。如果我 运行 我的应用程序下面的代码从 AppLocalization.resx 文件中获取正确的字符串:

ResourceManager ^rm1 = gcnew ResourceManager(L"My_App.AppLocalization", Assembly::GetExecutingAssembly());
this->Text = rm1->GetString(L"My String Name");

现在我想测试 .fr 法语翻译,这就是我遇到问题的地方。这两个都无法从 .fr.resx 文件中获取字符串,而是 return 从 AppLocalization.resx 文件中获取字符串:

this->Text = rm1->GetString(L"My String Name", gcnew System::Globalization::CultureInfo("fr"));

System::Threading::Thread::CurrentThread->CurrentCulture = gcnew System::Globalization::CultureInfo("fr-FR");
System::Threading::Thread::CurrentThread->CurrentUICulture = gcnew System::Globalization::CultureInfo("fr-FR");
this->Text = rm1->GetString(L"My String Name");

毫无疑问,它会很简单我做错了或没有设置,但经过多次搜索我找不到解决方案。我试过在调试模式和发布模式下进行测试。我已验证文件 \fr\My_App.resources.dll 正在 Debug 和 Release 文件夹中创建,但无论我尝试什么,它都不会在 运行 时间被使用。

问题是.....我的项目属性 "Common Language Runtime Support" 设置为“/clr:safe”。一旦我将其更改为“/clr:pure,一切都完美无缺。