问题
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