Can C++/CLI .NET use resource .resx files for localization?

眉间皱痕 提交于 2019-12-22 10:37:26

问题


I am trying to localize a managed C++ .NET DLL for multiple languages. The forms are easy enough because they operate just like the other languages and create multiple .resx files.

I cannot find any examples of localizing embedded strings in managed C++, other than to use .RC string tables in the traditional C++ way. Is there any way to use .resx resource files to facilitate use with resource editors like Zeta, etc?


回答1:


Create a separate resources file in managed C++ containing all the error messages of the application. To do that, right-click on your managed C++ project in the solution explorer and Add / New Item of type Assembly Resource File (.resx). Give it the name MyMessages.resx for example.

Add your strings there, for example a message with the name "Error".

In your code you can retrieve the string as follows, assuming that your root namespace name is "MyApp".

Resources::ResourceManager^ rm = gcnew Resources::ResourceManager(L"MyApp.MyMessages", this->GetType()->Assembly);

MessageBox::Show(rm->GetString(L"Error"));

You can later localize your error messages in French for example, by creating another Assembly Resource File with the name MyMessages.fr.resx.




回答2:


You actually can use *.resx to localize your applications:

.NET Localization, Part 1: Resource Managers

.NET Localization, Part 2: Creating Satellite Assemblies



来源:https://stackoverflow.com/questions/11398407/can-c-cli-net-use-resource-resx-files-for-localization

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!