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,
Function to get String ID
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!
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!
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.
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.
Best regards,
Igor Siticov.
Igor Siticov.
-
- Posts: 65
- Joined: Thu May 08, 2008 7:46 pm
Re: Function to get String ID
We also did need to find IDS from string and developped some code to do it.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?
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: Select all
Dialog('Please check node #' + IntToStr(NodeNumber) + ', it does not respond!')
Code: Select all
Dialog(format(GlobalStr_NodeNotResponding, [NodeNumber]))
Code: Select all
GlobalStr_NodeNotResponding = 'Please check node #%d, it does not respond!'
Code: Select all
'Pas de réponse du noeud #%d!'
Jean-Paul Brassard
Quebec, Canada
Quebec, Canada