strings need translation before form is created

All announcements, questions and issues related to the TsiLang Components Suite.
Post Reply
DavidD
Posts: 17
Joined: Wed Mar 07, 2007 9:19 pm
Location: United States

strings need translation before form is created

Post by DavidD »

Hoo boy, we have gotten too tricky. The situation is this:
unit
interface
type
TfrmViewer = class(ancestor viewer with TsiLang component)
public
class function ShowItems (formCaption: String): Boolean;
end;

function ShowItems1: boolean;
function ShowItems2: boolean;

implementation

function ShowItems1: boolean;
begin
result := TfrmViewer.ShowItems('Widgets');
end;

function ShowItems2: boolean;
begin
result ;= TfrmViewer.ShowItems('Stuff');
end;

I need to access my global TsiLang component for the GetTextorDefault, not the inherited one on the form since it does not exist yet. Is that possible?

For the moment, I have changed this to pass in an integer value parameter instead of the string title and use it to assign the Form.Caption string after the form is created.

Note, There are other strings in the TfrmViewer procedures that will be translated by the inherited component.
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

just use:
YOUR_ALREADY_CREATED_FORM.siLang.GetTextOrDefault() to get strings from another form which is created at this time.
Best regards,
Igor Siticov.
DavidD
Posts: 17
Joined: Wed Mar 07, 2007 9:19 pm
Location: United States

Post by DavidD »

When would I make the change to specify the already created form?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Where you need them.
The idea is:
1. Move your strings from inherited form to the base one or one which is already created in that moment.
2. In code of TfrmViewer class function use strings from TsiLang on created form not from TsiLang on this form because no any object created in class function.

Because this is not a TsiLang but global design problem. You won't be able to use anything related to classes (objects) of TfrmViewer before creting it or creating these objects manually in class function.
Best regards,
Igor Siticov.
DavidD
Posts: 17
Joined: Wed Mar 07, 2007 9:19 pm
Location: United States

Post by DavidD »

Yah, I know it's not a TsiLang problem. Let me just confirm a couple of things. My already created form is dmInternational.
I will need to manually copy the strings from the TfrmViewer siLang component properties to the dmInternational.siLang component properties and assign it an IDS_xxx ID unique within dmInternational. Then make sure the dmInternational.siLang.GetText(IDS_xxx) references the new unique ID. Correct?

I notice theTsiLang Files Editor will not allow me to edit the String ID column. Is there a way to allow this so I could just change the StringID there without having to copy?
isiticov
Site Admin
Posts: 2383
Joined: Thu Nov 21, 2002 3:17 pm

Post by isiticov »

Yes, you're correct.
You can easily select and copy strings using TsiLang Translation Editor (double-click on TsiLang). It allows to select and edit StringID column.
SIL Editor prevents this in order to protect your IDs from "bad" translators.
Best regards,
Igor Siticov.
Post Reply