0

I'm trying to use .resx files for string localization in a managed C++ CLR project with VS2013. In my projects Resources Files folder I right click > Add Item > .resx file and name it AppLocalization.resx. I do it again and create AppLocalization.fr.resx. Then I add a different string with the same name to each. If I run my application the following code gets the correct string from the AppLocalization.resx file:

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

Now I want to test the .fr French translation and this is where I'm having trouble. Both of these fail to get the string from the .fr.resx file and instead return the string from the AppLocalization.resx file:

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");

No doubt its going to be something simple I'm doing wrong or haven't set, but after much searching I can't find the solution. I've tried testing in both debug mode and release mode. I have verified the file \fr\My_App.resources.dll is being created in the Debug and Release folders, but whatever I try it isn't used at run time.

Skanky
  • 129
  • 8
  • I never did figure out how fallback from a specific culture like "fr-FR" to a neutral culture like "fr" works. Other than having run into trouble before with it. – Hans Passant Jan 21 '15 at 16:53
  • It's not a fall back issue as it fails to work with "fr" or "fr-FR" (I've tried both everywhere) – Skanky Jan 21 '15 at 17:10
  • Having received no answers to this after 2 days I'm wondering if this means others have not experienced the same issue? I know the above just works with C# from the extensive searching I have done, but I am using C++ which sometimes requires extra settings to be made for projects on issues like this. I wonder if any other C++ users tell me if they have done the above successfully with no issue, in which case it must be something specific to my project? – Skanky Jan 23 '15 at 10:24

1 Answers1

0

And the problem was.....my project properties had "Common Language Runtime Support" set to "/clr:safe". Once I changed it to "/clr:pure everything worked perfectly.

Skanky
  • 129
  • 8