6.0.1: Bug in TsiLangDispatcher?

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
markjan
Posts: 12
Joined: Wed Feb 08, 2006 12:00 pm

6.0.1: Bug in TsiLangDispatcher?

Post by markjan »

In procedure TsiLangDispatcher.LoadAllFromFile (in siComp.pas), there is a code section that reads

Code: Select all

  for I := 0 to FSIComponents.Count - 1 do
    TsiCustomLang(FSIComponents[0]).Loaded;
should that not be

Code: Select all

  for I := 0 to FSIComponents.Count - 1 do
    TsiCustomLang(FSIComponents[I]).Loaded;
?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Yes, definitely this is mistype bug. You're correct it must look as you described. We will fix this. Thank you for your notice!
Best regards,
Igor Siticov.
markjan
Posts: 12
Joined: Wed Feb 08, 2006 12:00 pm

Post by markjan »

OK; in the same method I also noticed

Code: Select all

  if FSIComponents.Count > 0 then
  begin
    FLangNames.Assign(TsiCustomLang(FSIComponents[0]).FLangNames);     
    FNumOfLanguages := TsiCustomLang(FSIComponents[0]).NumOfLanguages;
  end;
should that not be

Code: Select all

  if FSIComponents.Count > 0 then
  begin
    LangNames.Assign(TsiCustomLang(FSIComponents[0]).FLangNames);     
    NumOfLanguages := TsiCustomLang(FSIComponents[0]).NumOfLanguages;
  end;
? Note the difference in using the setters for these properties. This is relevant if the external file contains a different number of languages compared to the design-type values.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

No, this code is correct and must be as it is.
Best regards,
Igor Siticov.
markjan
Posts: 12
Joined: Wed Feb 08, 2006 12:00 pm

Post by markjan »

OK, but I get an ELanguageError after running this code. It happens when the .sib file has more languages than are defined design-time. The LoadAllFromFile completes OK, but when I later set the LangDispatcher.ActiveLanguage property to the new value, I get the error message because one of the TsiLang components has a lower NumOfLanguages value.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

I guess the problem is in very rare case (and it might be your case) when first TsiLang in disptacher's list has less languages defined in SIB file than others and as result dispatcher receives lower values. I suggest it is better to correct the SIB file.
Best regards,
Igor Siticov.
markjan
Posts: 12
Joined: Wed Feb 08, 2006 12:00 pm

Post by markjan »

I did check the .sib file with the SILEditor (that's how I added the new language to it), and as far as I can see all units and forms show that language column. How would I 'correct' the sib file in this case?

Also, please understand that this is not an exotic problem. We want to be able to have users add a new language by allowing them to edit the .sib file using the SILEditor. Those languages will not be pre-defined in the TsiLangDispatcher in the executable. So loading new languages from the .sib file should work seamlessly for us.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Actually, this is quite usual way allowing users to define their own languages. And we ourselves use same technique in our Resource Builder. Users able to add new languages there as well.

If SIB file lists all languages correctly, then the problem might be somewhere else. May be there is one form in your project, which is not included in the SIB file and it might cause such problem.
Best regards,
Igor Siticov.
markjan
Posts: 12
Joined: Wed Feb 08, 2006 12:00 pm

Post by markjan »

The code fragment I posted above solves the problem; does that give you any clue as to where the problem is?

As to a form missing from the sib file: I created it from the Language Expert doing a 'Save Project' from it - so I assume that includes all forms in the project.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

You're right, we've found the case when our code might not work correctly. Your code must be used with small improvement:

Code: Select all

if FSIComponents.Count > 0 then 
  begin 
    LangNames := TsiCustomLang(FSIComponents[0]).FLangNames;      
    NumOfLanguages := TsiCustomLang(FSIComponents[0]).NumOfLanguages; 
  end; 
This code is a little bit overfull but in order just to be sure that all linked TsiLangs have all properties synchronized with dispatcher.

Thank you again for your help!
Best regards,
Igor Siticov.
markjan
Posts: 12
Joined: Wed Feb 08, 2006 12:00 pm

Post by markjan »

No problem; can I assume these changes will be applied in the next update?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Yes, of course!
Best regards,
Igor Siticov.
Post Reply