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 

Load .sib strings from console application (c++)

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



Joined: 06 Mar 2015
Posts: 2

PostPosted: Fri Mar 06, 2015 12:30 pm    Post subject: Load .sib strings from console application (c++) Reply with quote

Hi all,

Is possible to load strings from a .sib file in a console application or DLL with no forms?

Obviously I can't use TSilang design component, I'm creating component by code from scratch.

I've tried following with no luck:

siLang = new TsiLang(0); <-- 0: No form reference
siLang->Name = "KLang";
siLang->NumOfLanguages = 2;
siLang->ActiveLanguage = 1;
siLang->LangNames->Add("Spanish");
siLang->LangNames->Add("Italian");
siLang->LoadFromFile(stStrings,".\Test.sil",true);
siLang->LoadPropFromBinaryFile("Strings","Test.sib");
siLang->LoadAllFromBinaryFile("Test.sib");
int c = siLang->Strings->Count;


What am I doing wrong?

Thanks!
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Fri Mar 06, 2015 8:09 pm    Post subject: Reply with quote

Hello,

1. TsiLang requires owner such as form or datamodule in order to be able to use "save/load functionality".
2. When you set NumOfLanguages property TsiLang automatically adds/removes languages from LangNames property. So you would need just to assign the value for LangNames[Index] property instead of adding.

So I would recommend to just add datamodule to your console application and manage translations using it.
Back to top
View user's profile Send private message
jcanom



Joined: 06 Mar 2015
Posts: 2

PostPosted: Mon Mar 09, 2015 3:55 pm    Post subject: Reply with quote

You're right, I've tried with both DataModule and Form and it works in both ways:

Ex1:
TComponent *t = new TComponent(0);
TForm *f = new TForm(t);
TsiLang *s = new TsiLang(f);
s->LoadAllFromBinaryFile("hi.sib");
str = s->GetTextOrDefault("asfa");
Ex2:
TDataModule *dm = new TDataModule(0);
TsiLang *s = new TsiLang(dm);
s->LoadAllFromBinaryFile("hi2.sib");
str = s->GetTextOrDefault("asfa");

This works perfectly, but the most important thing to care about is .sib structure, it is linked with the TsiLang parent component...

Ex 1 .sib : hi.sib
-> TForm
-->Strings
----> asfa

Ex 2 .sib: hi2.sib
-> TDataModule
--> Strings
----> asfa

Knowing this I can handle a solution to my problem but...

Is possible to load .sib file with many forms data and choose strings you want to load, breaking the linkage between .sib and parent name?

Example:

.sib :
+ TForm1
--> Strings
+ TForm2
--> Strings <--- load TForm2 for ex.
+ TForm3
--> Strings

I'll try to explain you my case to understand my context. I already have a project running with all the translations inside a .sib, and I want to reuse this .sib extracting the translations from TForm1-->Strings but in my DLL I don't have Form1.

Thanks for your fast reply!
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2103

PostPosted: Wed Mar 11, 2015 2:18 pm    Post subject: Reply with quote

TSIBFileManager class could be used to work with SIB files without actual forms. You can use CreateByName(FileName) constructor to instantiate it with preloaded SIB file and then iterating through siComponents[Index] you can get translations loaded.
Hope this helps.
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