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

拟墨画扇 提交于 2019-12-06 03:49:52

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.

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