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 

Function to get String ID

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



Joined: 14 Nov 2008
Posts: 8

PostPosted: Mon Mar 09, 2009 11:56 pm    Post subject: Function to get String ID Reply with quote

Hi,

As we know we read strings form SIL by using siLang->GetTextOrDefault("IDS_0") by default, my question is that is there a funfction that can return String ID in Strings property by providing string contents (AnsiString) and language ID(Int or AnsiString) as parameters? Or something similar to this?

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


Joined: 21 Nov 2002
Posts: 2097

PostPosted: Wed Mar 11, 2009 11:24 am    Post subject: Reply with quote

Hi,

Unfortunately, there is no such method.
Back to top
View user's profile Send private message
Riquleme



Joined: 14 Nov 2008
Posts: 8

PostPosted: Wed Mar 11, 2009 6:37 pm    Post subject: Reply with quote

Hi isiticov,

Thanks for your reply.

The reason why I need this is that I have many forms which have not only their own strings, but they also have some common strings, so I think I need to make a common SIL file which should be merged by each form at run-time. That is why I need the access to each newly merged string ID and to use it, otherwise how do I call GetTextOrDefault(stringID), the source code has no idea about what stringID is.

I hope I explain clearly, and is there any alternative to do that ?

Thank you very much!
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2097

PostPosted: Fri Mar 13, 2009 3:57 am    Post subject: Reply with quote

Hello,

This is not an easy task and I would recommend you to re-think if you need to implement this.
If you still decide to use this approach you can use the following:
1. At run-time TsiLang has FStringsColl protected field, which is TsiStringsCollection.
2. This collection holds all strings and their translations. Every item has ID property which is String ID and Values.
3. So you can iterate through all the collection items to check their ID and perform any modifications you need.

Hope this helps.
Back to top
View user's profile Send private message
Jean-Paul Brassard



Joined: 08 May 2008
Posts: 65

PostPosted: Thu Mar 26, 2009 4:20 pm    Post subject: Re: Function to get String ID Reply with quote

Riquleme wrote:
As we know we read strings form SIL by using siLang->GetTextOrDefault("IDS_0") by default, my question is that is there a funfction that can return String ID in Strings property by providing string contents (AnsiString) and language ID(Int or AnsiString) as parameters? Or something similar to this?

We also did need to find IDS from string and developped some code to do it.
1) a method to read SIB files and get all the IDS and their translations;
2) a method to search a given string in a given language and get back its IDS;
3) a method to add these strings into the TsiLang strings collections (as pointed out by Igor).

But you could also fullfill your need with TsiLang standard methods.
1) create a new DataModule on which you drop a TsiLang component;
2) move all your common strings into that module;
3) add a reference to it in your Use sections;
4) add test in your App Initialization to create this DataModule if not done yet.

N.B. While mooving your strings, you should concatenate groups of strings into complete sentences, such as this:
Code:
Dialog('Please check node #' + IntToStr(NodeNumber) + ', it does not respond!')

which should be replace with this:
Code:
Dialog(format(GlobalStr_NodeNotResponding, [NodeNumber]))

Then, in your DataModule, you should find this declaration:
Code:
GlobalStr_NodeNotResponding = 'Please check node #%d, it does not respond!'

Then, in your SIB or SIL, you would be free to reverse the position of the words in your sentence, according to the destination language, such as:
Code:
'Pas de réponse du noeud #%d!'
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