|
|
Clarion 6 - General
Started by Carl Bergman at 09-14-2008 10:40 AM. Topic has 3 replies.
 
 
|
|
Sort Posts:
|
|
|
|
09-14-2008, 10:40 AM
|
Carl Bergman
Joined on 03-21-2007
Finland
Posts 10
|
Translator ExtractText Question
|
|
|
|
|
|
I am using translator class and want to extract runtime user interface text by using the command extractText('filename').
Since there is a lot of text I would like to extract text from each procedure into its own .txt-files.
I got it to work somehow but problem is that each .txt-files ends up containing both the wanted interface text from procedure in focus as well as unwanted interface text from the main procedure.
How can I prevent text from main procedure to be output to these files?
|
|
|
|
|
Report
|
|
|
|
09-14-2008, 5:47 PM
|
samir
Joined on 05-21-2008
Posts 28
|
Re: Translator ExtractText Question
|
|
|
|
|
Hello Carl,
1- Locate the translatorClass in abutil.inc
2- Add the following method:
FreeQ Procedure()
3- Add the following to your abutil.clw
TranslatorClass.FreeQ PROCEDURE()
code
Free(Self.Queue)
4- Issue Translator.FreeQ whenever you need in your app. That's it.
Regards,
Samir
|
|
|
|
|
Report
|
|
|
|
09-15-2008, 5:05 AM
|
Carl Bergman
Joined on 03-21-2007
Finland
Posts 10
|
Re: Translator ExtractText Question
|
|
|
|
|
|
Samir,
thanks for pointing me in the right direction and explaining things very clear.
But I am still having some problems:
Depending on where I call the Translator.FreeQ in the child procedure I end up with interface text from both main- and child procedure OR no interface text at all.
So I wonder at what point in the child procedure the Translator-queue gets filled with interface text? (i.e. what would be the correct embed to free the queue from main procdure interface text but allow it to get filled with child procedure interface text?)
Regards,
Carl
|
|
|
|
|
Report
|
|
|
|
09-15-2008, 6:43 AM
|
samir
Joined on 05-21-2008
Posts 28
|
Re: Translator ExtractText Question
|
|
|
|
|
Hello Carl,
The translator queue gets filled with a startup list of translation pairs(70) which are found in abutil.trn. The translator extracts the window text soon after the window manager opens the window, it appends pairs to the current translator queue. You can message records(self.queue) inside Translator.FreeQ to find out how many records are there at any time.
The following code allows you to define a user queue inside your code. After passing this queue to the Translator.FillQ, you will get the queue filled by the entries of the built-in translator queue. Once the user queue is filled with entries, you can edit the queue or save it to disk file. At startup of the your application, you can use Translator.Addtranslation to add the pairs from your disk file rather than from groups. This way you can translate on line, save to disk and load your translations from disk file.
1- In abutil.inc, add the following before the TranslatorClass:
InQueue Queue,type
TextProp STRING(1024)
tc1 LONG
tc2 LONG
tc3 LONG
tc4 LONG
Replacement STRING(1024)
rc1 LONG
rc2 LONG
rc3 LONG
rc4 LONG
Mark LONG
END
2- Add the following method to the TranslatorClass.
FillQ Procedure(InQueue Q)
3- Add the following method to abutil.clw
TranslatorClass.FillQ PROCEDURE(InQueue Q )
i long
Err long
CODE
Free(Q)
Clear(Q)
LOOP i = 1 TO RECORDS (SELF.Queue )
GET (SELF.Queue , i)
if SELF.Queue.TextProp[1] = 's' and inrange(SELF.Queue.TextProp[2],1,9)
elsif SELF.Queue.TextProp[1] = 'n' and inrange(SELF.Queue.TextProp[2],1,9)
elsif SELF.Queue.TextProp[1:2] = 'n-'
else
Q.TextProp = clip(SELF.Queue.TextProp) & '<0>'
Q.Replacement = clip(SELF.Queue.Replacement) & '<0>'
Q.tc1 = -1
Q.tc2 = -1
Q.tc3 = -1
Q.tc4 = -1
Q.rc1 = -1
Q.rc2 = -1
Q.rc3 = -1
Q.rc4 = -1
Add( Q , Q.TextProp)
end
END
4- In your application, define the following queue:
TQUEUE QUEUE,PRE()
TextProp STRING(1024)
tc1 LONG
tc2 LONG
tc3 LONG
tc4 LONG
Replacement STRING(1024)
rc1 LONG
rc2 LONG
rc3 LONG
rc4 LONG
Mark LONG
END
5- Now calling translator.FillQ(TQueue) in your procedure will get your queue filled from the built-in queue. Drop a list on your window filling from your TQueue. Now TQueue is yours feel free to manipulate...
tc1.. allows you to colorize your list.
Regards,
Samir
|
|
|
|
|
Report
|
|
|
|
|
|