SiComponents Home Page SiComponents Forums
Here you will be able to get help and share your experience
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

6.0.1: Bug in TsiLangDispatcher?

 
Post new topic   Reply to topic    SiComponents Forums Forum Index -> TsiLang Components Suite
View previous topic :: View next topic  
Author Message
markjan



Joined: 08 Feb 2006
Posts: 12

PostPosted: Tue Feb 14, 2006 1:05 pm    Post subject: 6.0.1: Bug in TsiLangDispatcher? Reply with quote

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
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Tue Feb 14, 2006 1:16 pm    Post subject: Reply with quote

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
View user's profile Send private message
markjan



Joined: 08 Feb 2006
Posts: 12

PostPosted: Tue Feb 14, 2006 1:47 pm    Post subject: Reply with quote

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
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Tue Feb 14, 2006 1:52 pm    Post subject: Reply with quote

No, this code is correct and must be as it is.
Back to top
View user's profile Send private message
markjan



Joined: 08 Feb 2006
Posts: 12

PostPosted: Tue Feb 14, 2006 2:10 pm    Post subject: Reply with quote

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
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Tue Feb 14, 2006 4:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
markjan



Joined: 08 Feb 2006
Posts: 12

PostPosted: Tue Feb 14, 2006 5:09 pm    Post subject: Reply with quote

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
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Tue Feb 14, 2006 5:36 pm    Post subject: Reply with quote

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
View user's profile Send private message
markjan



Joined: 08 Feb 2006
Posts: 12

PostPosted: Thu Feb 16, 2006 9:24 am    Post subject: Reply with quote

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
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Thu Feb 16, 2006 10:45 am    Post subject: Reply with quote

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
View user's profile Send private message
markjan



Joined: 08 Feb 2006
Posts: 12

PostPosted: Thu Feb 16, 2006 1:45 pm    Post subject: Reply with quote

No problem; can I assume these changes will be applied in the next update?
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Thu Feb 16, 2006 1:56 pm    Post subject: Reply with quote

Yes, of course!
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    SiComponents Forums Forum Index -> TsiLang Components Suite All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by p h p B B  © 2001, 2005 p h p B B  Group