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!
Load .sib strings from console application (c++)
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.
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.
Best regards,
Igor Siticov.
Igor Siticov.
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!
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!