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 

How to UN-translate a string?

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



Joined: 02 Apr 2014
Posts: 2

PostPosted: Thu Apr 03, 2014 8:07 am    Post subject: How to UN-translate a string? Reply with quote

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.
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Fri Apr 04, 2014 1:37 pm    Post subject: Reply with quote

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.
Back to top
View user's profile Send private message
anudedeus



Joined: 02 Apr 2014
Posts: 2

PostPosted: Mon Apr 07, 2014 2:15 pm    Post subject: But my FStringsColl.count is 0 Reply with quote

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:

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;
Back to top
View user's profile Send private message
isiticov
Site Admin


Joined: 21 Nov 2002
Posts: 2102

PostPosted: Tue Apr 08, 2014 6:47 am    Post subject: Reply with quote

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.
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