Page 1 of 1

6.0.1: Bug in TsiLangDispatcher?

Posted: Tue Feb 14, 2006 1:05 pm
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;
?

Posted: Tue Feb 14, 2006 1:16 pm
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!

Posted: Tue Feb 14, 2006 1:47 pm
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.

Posted: Tue Feb 14, 2006 1:52 pm
by isiticov
No, this code is correct and must be as it is.

Posted: Tue Feb 14, 2006 2:10 pm
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.

Posted: Tue Feb 14, 2006 4:09 pm
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.

Posted: Tue Feb 14, 2006 5:09 pm
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.

Posted: Tue Feb 14, 2006 5:36 pm
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.

Posted: Thu Feb 16, 2006 9:24 am
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.

Posted: Thu Feb 16, 2006 10:45 am
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!

Posted: Thu Feb 16, 2006 1:45 pm
by markjan
No problem; can I assume these changes will be applied in the next update?

Posted: Thu Feb 16, 2006 1:56 pm
by isiticov
Yes, of course!