简体   繁体   中英

localization with c++ builder 2009 reinit.pas

I am loacalizing a RAD Studio 2009 C++ Builder project. In the IDE I can use Project/Language/Acivate to choose a language before the program starts. That works fine. Now I want to change languages at runtime. In order to do that I need the Delphi unit reinit.pas which curiosly enough, isn't included in my installation. I found two versions somewhere on the net. The one is dated Aug.9,2002. The other one is dated March 9, 2013. There are two buttons on the form which call the respective methods below in order to switch to the appropriate language.

void __fastcall TFormMonitor::ButtonEnglishClick(TObject *Sender)
{
const cEnglish = MAKELANGID(LANG_ENGLISH, SUBLANG_ENGLISH_US);
if(LoadNewResourceModule(cEnglish))
{
ReinitializeForms();
}
}

//---------------------------------------------------------------------------
void __fastcall TFormMonitor::ButtonDeutschClick(TObject *Sender)
{
const cGerman = (SUBLANG_GERMAN | LANG_GERMAN);
if(LoadNewResourceModule(cGerman))
{
ReinitializeForms();
}
}

Both versions of reinit.pas have the same behavior. ReinitialzeForms() throws a class EReadError excecption with the comment "Ancestor not found".

Where can I get a version of reinit.pas that matches the C++ Builder 2009?

Or is the EReadError exception caused by some the problem?

I've aleady done hours of researching on the net and have not come up with a solution.

Thanks for your help, Derl

This error is raised because there is one or more components whose Name property is empty (""). To solve this problem, the empty-Name component should be found and set a name. The code to find the empty-name component in the application is:

TComponent *pform, *pcomponent;
AnsiString NoNameComponent;

for( int ff=0; ff< Application->ComponentCount; ff++) {   
    pform = Application->Components[ff];  // get a form
    for( int i=0; i< pform->ComponentCount; i++ ) {        
        pcomponent = pform->Components[i];  // get a component
        if( pcomponent->Name == "" )  {
          NoNameComponent = pcomponent->ClassName()
                  +" at "+pform->Name + "has no name";
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM