How to UN-translate a string?

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
anudedeus
Posts: 2
Joined: Wed Apr 02, 2014 10:52 am

How to UN-translate a string?

Post by anudedeus »

My default language is English, but the user configuration might be using for example Portuguese in the application (i.e. the active language is Portuguese).
How do I use any tranlated word (a string in a const section) that is currently translated to Portuguese and find out the original English(default) word?

For example, the Portuguese word for 'street' is 'rua'.
When I find the string 'rua' in my application, I want to revert it back to 'street', without having to change the active language, I just need to know where 'rua' came from.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Hello,

There is FStringsColl protected property of TsiLang which is TsiStringsCollection. You can iterate through its Items property and check their Values[LanguageIndex] property to detect if your current string matches it. Then retrieve Values[0] (which is assumed to be default) to get default value.
Hope this helps.
Best regards,
Igor Siticov.
anudedeus
Posts: 2
Joined: Wed Apr 02, 2014 10:52 am

But my FStringsColl.count is 0

Post by anudedeus »

Thanks, but for some reason, even though I have 21 languages loaded, the collection count is still 0.
See example below, what am I doing wrong?

Code: Select all

type TAccessTsi = class(TsiCustomLang);

procedure TMyForm.StatusBarDblClick(Sender: TObject);
var 
lStr : TsiStringsCollection;
 s : String;
 i : Integer;
 L : Integer;
begin
  s := 'Departamento';
  lStr :=  TAccessTsi(siLang1).FStringsColl;
  L := 5;
  for I := 0 to lStr.Count -1 do //<<<<< [b]THIS COUNT IS ALWAYS 0!![/b]
  begin
     if lStr[i].Values[L] = s then
       outputdebugstring(pchar('Found it: '+lStr[i].Values[0]))
     else
       outputdebugstring(pchar('not yet: '+lStr[i].Values[L]));
  end;
end;
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

May be Strings property of TsiLang is empty in your case? FStringsColl uses Strings property. If you need to retrieve the default value for ANY string then you would need to iterate through all TsiLang translation properties like Captions, Hints and so on and test the value.
Best regards,
Igor Siticov.
Post Reply