3

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?

4

2 回答 2

8

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.

于 2012-07-09T17:40:15.887 回答
0

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

.NET Localization, Part 1: Resource Managers

.NET Localization, Part 2: Creating Satellite Assemblies

于 2012-07-09T16:54:38.020 回答