Article

From:
To:
Bruce Petty
Subject:
Re: Build fails for language files
Newsgroup:
embarcadero.public.cppbuilder.localization

Re: Build fails for language files

Hi Bruce,

I discovered that when you change the active language in the IDE it creates (or modifies) two registry keys in HKEY_CURRENT_USER/Software/Embarcadero/Locales. The keys are named after the path and filename of your project so in my case they are called C:\Users\Ciaran\Documents\RADStudio\Projects\ITE-Test\.\Win32\Release\Project1.exe and C:\Users\Ciaran\Documents\RADStudio\Projects\ITE-Test\Win32\Release\Project1.exe These both seem to point to the same folder so I don't know why one has a (redundant) "./" in the path. When I set my active language to French the contents of both of these is "FRA" and when I change it ti English the contents are "en-GB".

The catch seems to be that it takes while for the IDE to realise that the path to the project has changed since when I looked at this after first changing my active language to French I found two entries as above with FRA as the locale BUT with a space in "RAD Studio". When I ran the program it showed the English version of the form. When I changed it back to English and then Back to French again I ended up with the correct registry entries and the program now displays the Frence version if I run it i
n the IDE.

I can see that I have Project1.exe and Project1.FRA files in my release folder and my understanding is that if I deploy the FRA file with the application then anyone whose PC is set to a french locale will load the form and strings from that file instead of the exe file however I have not yet tried that.

Just for the sake of completeness there is a bit of sample code on the embarcadero website http://docwiki.embarcadero.com/RADStudio/XE3/en/Dynamic_Switching_of_Resource_DLLs showing how to switch languages at runtime and the code is as follows.

{code}
const FRENCH = (SUBLANG_FRENCH << 10) | LANG_FRENCH;
 
if (LoadNewResourceModule(FRENCH))
    ReinitializeForms();
{code}

However if you try to use this you discover that LoadNewResourceModule() and ReinitializeForms are not recognised functions. It turns out that this code calls functions defined in reinit.pas which is part of the RichEdit sample project that comes with RAD Studio. In the ..Samples/Delphi/VCL/Richedit folder. This sample project apparently lets you select one of four languages and switches between them on command. However the sample is a Delphi Project and I only have the C++ version of RAD Studio so I can't use it. I haven't tried converting the code to C++ and I'm not sure whether SUBLANG_FRENCH and LANG_FRENCH are predefined constants or whether they also rely on the reinit.pas file.

I think your best option is to change the active language a couple of times and check the registry entries. You can edit the registry by hand if needed. Apparently you just need a single entry named with the full path to your program file and containing the locale code that you require as detailed here http://docwiki.embarcadero.com/RADStudio/XE3/en/Using_Resource_DLLs

Regards

Ciaran
> {quote:title=Bruce Petty wrote:}{quote}
> Hi Ciaran!
> Thank you so much for responding. I did not expect anyone to respond. I had tried Embarcadero and they wanted $300 to tell me how to get around their bug.
> I first tried to translate a Hello World program with XE and then used the trial XE3 and got the same response. Your work-around worked! It did allow the build without failure however after doing a Project->Language->Set Active to change the language and then the Build All Projects, the program which Runs still shows only English. I put other words in for both the Form Caption and a single TLabel caption.
> During some of the early discussion with Embarcadero they gave me a link to:
> http://cc.embarcadero.com/item/26954
> which is a webinar where the lecturer talks about doing a translation. Unfortunately most of the lecture just shows a black screen because the webinar was apparently live and so only shows the few saved Power Point images but then goes black when the lecturer is trying to demonstrate something.
> If you have ever been able to do a complete translation and gotten it to actually show a different language when running, I would be very grateful to know how you did it.
> Any helpful links would be much appreciated. I've read everything (I think) that Embarcadero has put out.
> Bruce
FYI: Phrase searches are enclosed in either single or double quotes
 
 
Originally created by
Tamarack Associates
Tue, 05 Nov 2024 11:41:03 UTC
Copyright © 2009-2024
HREF Tools Corp.