Extracting strings from a TsiLangLinked

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
clauer
Posts: 2
Joined: Wed Dec 04, 2002 10:07 pm

Extracting strings from a TsiLangLinked

Post by clauer »

Hi,

I'd like to build action bars (menu and tools) at run time. To do this I must know the names of the actions. As long as I use one language, this is easy to achieve, using more than one language, extracting the from TsiLangLinked strings in the language selected would be more convenient.

So I tried 'itemName := lngUStart.OtherStrings.Values[actDBFirst.Category]' but nothing was returned. The name 'actDBFirst.Category' can be found in 'Other strings' using Translation editor - Other.

With 'lngUStart.OtherStrings.GetText' (or .CommaText or .DelimitedText) I get all entries in 'Other strings' but I only want exactly one which has to be in the language choosen.

'itemName := lngUStart.OtherStrings.ValueFromIndex[index]', which returns all translations of an entry including its name with the first letter cut off, would be no good choice because the index may vary while the name of an entry doesn't.

The same applies to 'Captions'.

How can I get the correct language entry as a string from 'Captions' and 'Other'?

Thanks for your help!
Christian Lauer
gaivans
Posts: 71
Joined: Fri Nov 29, 2002 4:10 pm

Extracting string value

Post by gaivans »

Hello,

You can use the method:
function TsiCustomLang.GetStringValue(AStrings: pStrings; AName: TString; ALang: integer): TString;
where AStrings is the pointer to strings data (@Captions, @Hints, etc), AName is a string identifier, and ALang is the number of language to be extracted.

For example, after execution
...
with lngUStart do
itemName := GetStringValue(@OtherStrings, 'actDBFirst.Category', 2);
...
the itemName should contain translation of "actDBFirst.Category" for the language #2.

If you want to extract translation corresponding to the active language you can also use the .GetTextFrom method. For example:
...
with lngUStart do
itemName :=GetTextFrom(@OtherStrings, 'actDBFirst.Category', False);
...
Note, if the last parameter is False, this method returns empty string if no translation available.

Best regards,
Serghei Gaivan
Post Reply