View previous topic :: View next topic |
Author |
Message |
markjan
Joined: 08 Feb 2006 Posts: 12
|
Posted: Tue Feb 14, 2006 1:05 pm Post subject: 6.0.1: Bug in TsiLangDispatcher? |
|
|
In procedure TsiLangDispatcher.LoadAllFromFile (in siComp.pas), there is a code section that reads
Code: | for I := 0 to FSIComponents.Count - 1 do
TsiCustomLang(FSIComponents[0]).Loaded;
|
should that not be
Code: | for I := 0 to FSIComponents.Count - 1 do
TsiCustomLang(FSIComponents[I]).Loaded;
|
? |
|
Back to top |
|
 |
isiticov Site Admin
Joined: 21 Nov 2002 Posts: 2112
|
Posted: Tue Feb 14, 2006 1:16 pm Post subject: |
|
|
Yes, definitely this is mistype bug. You're correct it must look as you described. We will fix this. Thank you for your notice! |
|
Back to top |
|
 |
markjan
Joined: 08 Feb 2006 Posts: 12
|
Posted: Tue Feb 14, 2006 1:47 pm Post subject: |
|
|
OK; in the same method I also noticed
Code: | if FSIComponents.Count > 0 then
begin
FLangNames.Assign(TsiCustomLang(FSIComponents[0]).FLangNames);
FNumOfLanguages := TsiCustomLang(FSIComponents[0]).NumOfLanguages;
end; |
should that not be
Code: | 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. |
|
Back to top |
|
 |
isiticov Site Admin
Joined: 21 Nov 2002 Posts: 2112
|
Posted: Tue Feb 14, 2006 1:52 pm Post subject: |
|
|
No, this code is correct and must be as it is. |
|
Back to top |
|
 |
markjan
Joined: 08 Feb 2006 Posts: 12
|
Posted: Tue Feb 14, 2006 2:10 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
isiticov Site Admin
Joined: 21 Nov 2002 Posts: 2112
|
Posted: Tue Feb 14, 2006 4:09 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
markjan
Joined: 08 Feb 2006 Posts: 12
|
Posted: Tue Feb 14, 2006 5:09 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
isiticov Site Admin
Joined: 21 Nov 2002 Posts: 2112
|
Posted: Tue Feb 14, 2006 5:36 pm Post subject: |
|
|
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. |
|
Back to top |
|
 |
markjan
Joined: 08 Feb 2006 Posts: 12
|
Posted: Thu Feb 16, 2006 9:24 am Post subject: |
|
|
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. |
|
Back to top |
|
 |
isiticov Site Admin
Joined: 21 Nov 2002 Posts: 2112
|
Posted: Thu Feb 16, 2006 10:45 am Post subject: |
|
|
You're right, we've found the case when our code might not work correctly. Your code must be used with small improvement:
Code: | 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! |
|
Back to top |
|
 |
markjan
Joined: 08 Feb 2006 Posts: 12
|
Posted: Thu Feb 16, 2006 1:45 pm Post subject: |
|
|
No problem; can I assume these changes will be applied in the next update? |
|
Back to top |
|
 |
isiticov Site Admin
Joined: 21 Nov 2002 Posts: 2112
|
Posted: Thu Feb 16, 2006 1:56 pm Post subject: |
|
|
Yes, of course! |
|
Back to top |
|
 |
|