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 

Loading from binary file

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



Joined: 30 Jul 2009
Posts: 34

PostPosted: Mon Nov 28, 2011 7:59 pm    Post subject: Loading from binary file Reply with quote

Hi

I have a problem using the TsiLang components and I need a help.

I need to load the translation files from SIB data but I will not leave the files on disk, instead I will do an architecture where I will store the translation files in a DLL as a resource and load it from stream later in the software

My problem is loading this for all the forms. If I use LoadAllFromStream in the dispatcher, it will only load the language file for the current created forms, but I need to load for future forms as well. I saw that to achieve that I need to set property Filename in dispatcher, but I wont send the .SIB files with my software, I want all SIB files to be inside a DLL file.

What can I do?

I dont want to manually call LoadAllFromBinaryStream for all TsiLangLinked component in all forms that I have, that will break all the concept of the Dispatcher...

I think that when I call LoadAllFromStream in the dispatcher, it should store the stream somewhere and when the TsiLangLinked components are actually linked to the dispatcher (By AddReference routine) it should load the stream.
Back to top
View user's profile Send private message
primarypower



Joined: 30 Jul 2009
Posts: 34

PostPosted: Thu Dec 01, 2011 1:19 pm    Post subject: Reply with quote

Please, I need a help
Im stuck in the development and I cant deliver my product!!! I hate depending on third party...
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2097

PostPosted: Sat Dec 03, 2011 8:14 am    Post subject: Reply with quote

Hello,

You can use OnLinkToDispatcher event to load stream content to the TsiLang.
Back to top
View user's profile Send private message
primarypower



Joined: 30 Jul 2009
Posts: 34

PostPosted: Mon Dec 05, 2011 5:35 pm    Post subject: Reply with quote

Dear Igor

I tried that... but the library gives me an exception, maybe Im using an old version of the library?
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2097

PostPosted: Tue Dec 06, 2011 1:08 am    Post subject: Reply with quote

What kind of exception do you get?
Back to top
View user's profile Send private message
primarypower



Joined: 30 Jul 2009
Posts: 34

PostPosted: Fri Dec 09, 2011 12:18 pm    Post subject: Reply with quote

Hi Igor

I actually got it working, but now I have another issue... I have some derived classes where the TsiLang control is placed on the first base form class, and I have translations in all layers (Base, 1 derivate and 2 derivate), the problem is that now when I load it from the stream (WHen linking to the dispatcher, it will not load the translations of the base and 1 derivate, just from the last derivate because the component is linked just once.

How can I automatically load the translations for the base and 1 derivate?
Back to top
View user's profile Send private message
primarypower



Joined: 30 Jul 2009
Posts: 34

PostPosted: Fri Dec 09, 2011 12:48 pm    Post subject: Reply with quote

Igor,

Since when the TsiLang component is linked to the dispatcher, the owner of the component is always the last derivative, I made the following code in order to load the translation of the 1 and base classes, check and please comment if it is safe to work this way

Code:
 

procedure TD_RecursosCM.tsiDispatcherLinkToDispatcher(Sender: TObject;
  ASiLang: TsiCustomLang);
var
  ParentClass: TClass;
begin

  // Check ownership
  if not Assigned(ASiLang.Owner) then
    Exit;

  // Get the owner class
  ParentClass := ASiLang.Owner.ClassType;

  // Load the translation for all parent classes
  while (Assigned(ParentClass)) and
        (ParentClass <> TForm) and
        (ParentClass <> TFrame) do
  begin

    // Load translation
    with TSIBFileManager.Create do
    try
      LoadFromStream(ASiLang, ParentClass.ClassName, FLocalizationData);
    finally
      Free;
    end;

    // Next parent
    ParentClass := ParentClass.ClassParent;

  end;

  // Update language
  ASiLang.UpdateStrCollections;
  ASiLang.ChangeLanguage;

end;


Im basically doing what your LoadAllFromBinaryStream does, but Im loading all translations from derivate classes and it actually worked... So, can I work this way or do you think that it is not safe...
Back to top
View user's profile Send private message
primarypower



Joined: 30 Jul 2009
Posts: 34

PostPosted: Fri Dec 09, 2011 2:28 pm    Post subject: Reply with quote

Well, didnt work out as I expected!!!

Loading the translations this way does not merge translation of ancestral classes

Please help me!
Back to top
View user's profile Send private message
primarypower



Joined: 30 Jul 2009
Posts: 34

PostPosted: Fri Dec 09, 2011 4:10 pm    Post subject: Reply with quote

I did a test, and I found that even if I use the external .sib file with my software by using:

Dispatcher.LoadAllFromFile and Dispatcher.FileName property

The same behaviour occur!
The translation component becomes useless when it comes to derived forms, all translation will be loaded only for the last descendant form, translation strings for ancestral forms wont be loaded so, what should I do?? I really really need this, I have many derived forms and the translation is not working and you take too much time to anwer my questions and my customers are really pushing me over here and I cannot deliver it!
Back to top
View user's profile Send private message
primarypower



Joined: 30 Jul 2009
Posts: 34

PostPosted: Fri Dec 09, 2011 4:11 pm    Post subject: Reply with quote

The version that Im using here is 6.5.0.1
I have to pay to get the latest version, so I will only upgrade if this is solved
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2097

PostPosted: Sat Dec 10, 2011 6:01 pm    Post subject: Reply with quote

Do you have IsInheritedOwner property set to True? When you open Translations Editor do you see ALL the translations in derived forms? That also should include translations from the base form. If you see all the translations then when you save to SIL/SIB file the file will contain all of them as well. As result when loading this file all the translations will be loaded.
You can always try this with the latest version. The trial version available on our web-site is fully functional and you can test all the functionality.
Please let us know if this helped.
Back to top
View user's profile Send private message
primarypower



Joined: 30 Jul 2009
Posts: 34

PostPosted: Mon Dec 12, 2011 5:00 pm    Post subject: Reply with quote

Hi Igor

I see your point.

The IsInheritedOwner is set to true, but no, I cant see translations of base forms

I remember deleting translation from base forms in derived forms, because when I change something in base form it was not changing in derived forms, and the strings were being stored twice, one for base form and anoher for derived form.

But anyway, I overcame this issue by creating a "hack" around the library. Basically I temporary load the translations of all base classes in temporary TsiLang components and manually merge the TStrings that holds the translations. It is working fine now... the only thing is that if you change this storing technique in the future I will have to change my code, but anyway, if we dont see an updated version that supports firemonkey in the future we will have to switch to another localization library, so, no problem
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