Page 1 of 1

strings need translation before form is created

Posted: Thu Apr 12, 2007 3:42 pm
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.

Posted: Thu Apr 12, 2007 4:34 pm
by isiticov
just use:
YOUR_ALREADY_CREATED_FORM.siLang.GetTextOrDefault() to get strings from another form which is created at this time.

Posted: Thu Apr 12, 2007 4:38 pm
by DavidD
When would I make the change to specify the already created form?

Posted: Thu Apr 12, 2007 5:07 pm
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.

Posted: Thu Apr 12, 2007 5:21 pm
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?

Posted: Fri Apr 13, 2007 2:10 am
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.