Automatic change of a translation
Automatic change of a translation
Hello again,
We are using siComponents for translating our apps for a half year and everything works fine.
Now we trying to get to another level: we want to allow customizing the interface (and not only) based on an equivalences table (database). That means, every occurence of a word (ex: "user") that have an equivalent ("author") into a specified table to be replaced with this "translation" on the GUI (at run time).
I'm thinking to use the siComponents for this, using the equivalences as a different "language". That would require an "on-the-fly" translation and a way to bring the equivalences into a sib file.
Is there any way to automatically fill a sib file? Something like looking for any occurence of the "user" word in the first column (language) and create the second column (language) string replacing "user" with "author". Then load the sib file at run time and switching to the second "language".
Is this feasible?
Is this the right way to do it?
Sorry for the many questions I have, but I try to find out if is there already a solution for this before I go further.
Thanks,
Ioan
We are using siComponents for translating our apps for a half year and everything works fine.
Now we trying to get to another level: we want to allow customizing the interface (and not only) based on an equivalences table (database). That means, every occurence of a word (ex: "user") that have an equivalent ("author") into a specified table to be replaced with this "translation" on the GUI (at run time).
I'm thinking to use the siComponents for this, using the equivalences as a different "language". That would require an "on-the-fly" translation and a way to bring the equivalences into a sib file.
Is there any way to automatically fill a sib file? Something like looking for any occurence of the "user" word in the first column (language) and create the second column (language) string replacing "user" with "author". Then load the sib file at run time and switching to the second "language".
Is this feasible?
Is this the right way to do it?
Sorry for the many questions I have, but I try to find out if is there already a solution for this before I go further.
Thanks,
Ioan
I don't want to create the SIB at run time, just modify it.
I have a table where my client can customize some items names. Like the "user" to be called "author".
I want to be able to read this table (at run time) and replace in my SIB file any occurence of "user" with "author", and then load the modified SIB.
Or, not changing the column for "Language1", but editing another "Language3" in SIB with the new name ("author") and then switching to "Language3".
I have a table where my client can customize some items names. Like the "user" to be called "author".
I want to be able to read this table (at run time) and replace in my SIB file any occurence of "user" with "author", and then load the modified SIB.
Or, not changing the column for "Language1", but editing another "Language3" in SIB with the new name ("author") and then switching to "Language3".
Hello,
Sorry for delay with reply.
ReplaceStringValue will replace the translation for specified language for defined value. So you will need to "know" the identifier of the string and language number.
I guess you don't need to modify a SIB but just translations internally stored in some TsiLang.
So you can use ReplaceStringValue method for this.
Please let me know if this helps.
Sorry for delay with reply.
ReplaceStringValue will replace the translation for specified language for defined value. So you will need to "know" the identifier of the string and language number.
I guess you don't need to modify a SIB but just translations internally stored in some TsiLang.
So you can use ReplaceStringValue method for this.
Please let me know if this helps.
Best regards,
Igor Siticov.
Igor Siticov.
I start working on this issue. I coded a function where I scan all the TsiLang TStrings properties (Captions, Hints, Strings, etc) and look for the string I want to replace. Then I retrieve the string ID and I call the ReplaceStringValue.
This function gets as input parameter the siLangLinked component of the current form as TsiCustomLang ( procedure CustomizeFields(siLang: TsiCustomLang); ).
After some tests I found out that the function seems to work properly, and I get the Strings values replaced, but not the Captions and other design features (I have only Multilines and Collections). I call the function on OnCreate form event (I also tried on OnShow). I logged into a file all the new and old values of the modified items and all seems to be properly replaced, but nothing changed on screen.
So, I think I miss something, maybe a kind of "refresh". Any idea?
Thanks,
Ioan
This function gets as input parameter the siLangLinked component of the current form as TsiCustomLang ( procedure CustomizeFields(siLang: TsiCustomLang); ).
After some tests I found out that the function seems to work properly, and I get the Strings values replaced, but not the Captions and other design features (I have only Multilines and Collections). I call the function on OnCreate form event (I also tried on OnShow). I logged into a file all the new and old values of the modified items and all seems to be properly replaced, but nothing changed on screen.
So, I think I miss something, maybe a kind of "refresh". Any idea?
Thanks,
Ioan
Re: Automatic change of a translation
Hello i tryed use ReplaceStringValue and ChangeLanguage in event OnCreate form event. OK It worked.
But in topic Change Font you wrote
I tryed it - see my code - but this not worked:
my version is 7.3.3
it looks simple, but something is wrong.
Can you help please?
Best regards
STevo
But in topic Change Font you wrote
I tryed it - see my code - but this not worked:
Code: Select all
procedure TDM.siLangDispatcher1LinkToDispatcher(Sender: TObject;
ASiLang: TsiCustomLang);
begin
if ASiLang.Owner.Name='Form1' then
begin
ASiLang.ReplaceStringValue(ASiLang.Captions,'ReplaceStringValue in Dispatcher','lblSLD',1);
ASiLang.ChangeLanguage;
end;
end;
it looks simple, but something is wrong.
Can you help please?
Best regards
STevo
Re: Automatic change of a translation
Hello,
Do you have dispatcher's FileName property set to some file? Because OnLinkToDispatcher is called first and then loading from the file is performed if FileName property of the dispatcher is set.
Do you have dispatcher's FileName property set to some file? Because OnLinkToDispatcher is called first and then loading from the file is performed if FileName property of the dispatcher is set.
Best regards,
Igor Siticov.
Igor Siticov.
Re: Automatic change of a translation
Yes
in DataModuleCreate i call
siLangDispatcher1.FileName := SibFile;
siLangDispatcher1.LoadAllFromFile(SibFile);
and after is call siLangDispatcher1LinkToDispatcher from Form1
Command ReplaceStringValue and ChangeLanguage was executed
in DataModuleCreate i call
siLangDispatcher1.FileName := SibFile;
siLangDispatcher1.LoadAllFromFile(SibFile);
and after is call siLangDispatcher1LinkToDispatcher from Form1
Command ReplaceStringValue and ChangeLanguage was executed
Re: Automatic change of a translation
As you have FileName property set then the sequence of actions/events is:
1. OnLinkToDispatcher event called.
2. Inside it you change translation.
3. LoadAllFromFile([Dispatcher's FileName]) called and your changes made on 2. are overwritten with values from file.
In short: if you have dispatcher's FileName property set changing translations in OnLinkToDispatcher won't work as they get overwritten with the values from the file.
1. OnLinkToDispatcher event called.
2. Inside it you change translation.
3. LoadAllFromFile([Dispatcher's FileName]) called and your changes made on 2. are overwritten with values from file.
In short: if you have dispatcher's FileName property set changing translations in OnLinkToDispatcher won't work as they get overwritten with the values from the file.
Best regards,
Igor Siticov.
Igor Siticov.