Internationalisation
Rob Cozens
rcozens at pon.net
Tue Jan 7 11:10:01 EST 2003
>My question is: what is the procedure for 'loading' all the text
>ONTO the interface?
G'Day Again, Igor.
What I related up to now comes from my Run Rev experience. The
HyperTalk version of OenoLog uses a more generalized approach where
individual text messages (which can be multiple lines) are placed in
separate fields and referred to by card & control ID instead of line
number..
Here is the HT handler that extracts stack help text in the installed language:
on mouseUp -- 4/21/01
global cancelTranslated,gimmieTime,myLanguage,okTranslated,whatFileTranslated
put the optionKey into optionState
if the icon of me > 20000 then exit mouseUp
speakup
set the hilite of me to false
allOff
put card field "Language" into saveLanguage
get myLanguage
put myFolder()&"OeNotes"&&it&":OeHelp"&&it&".txt" into fileName
delete the last char of it -- ")"
delete the first char of it -- "("
put it into card field "Language"
if optionState is up then
answer (field "Can't Quit Field Help") with cancelTranslated or
okTranslated
speakUp
else get okTranslated
if it is cancelTranslated then
put saveLanguage into card field "Language"
allOn
exit mouseUp
end if
open file fileName
if the result is not empty then
answer the result
ohOh
answer the result
answer (card field "Open Error Alert Help")&&fileName&"!"
speakUp
put saveLanguage into card field "Language"
allOn
exit mouseUp
end if
push card
put return&numToChar(215) into theDelimiter
put empty into backgroundList
set the cantAbort of this stack to true
lock screen
lock messages
go first
repeat
if "Image" is in the short name of this card then exit repeat
put true into doShared
put the short id of this card into cardId
get the short id of this background
if it is in backgroundList then
repeat with x = 1 to number of lines of backgroundList
if it = line x of backgroundList then put false into doShared
end repeat
end if
if doShared then put it&return after backgroundList
repeat with x = 1 to the number of background fields
set cursor to busy
put the short name of field x into fieldName
if fieldName is "Help" or "Result" is in fieldName then next repeat
if ("Help" is not in fieldName and "About" is not in fieldName
and "Title" is not in fieldName) or "Page Title" is in fieldName then
next repeat
if fieldName is in "Title,Index Title" then put line 2 of field
x into theMessage
else put field x into theMessage
if (theMessage <= " " and length(theMessage) < 2) then next repeat
put the sharedText of field x into shareMe
if doShared or not shareMe then
put the short id of field x into itemID
write
cardId&&itemID&&"BF"&&fieldName&return&theMessage&theDelimiter to
file fileName
end if
end repeat
repeat with x = 1 to the number of card fields
set cursor to busy
put the short name of card field x into fieldName
if "Help" is not in fieldName and "Title" is not in fieldName
then next repeat
put card field x into theMessage
if (theMessage <= " " and length(theMessage) < 2) or "Result"
is in fieldName then next repeat
put the short id of card field x into itemID
write
cardId&&itemID&&"CF"&&fieldName&return&theMessage&theDelimiter to
file fileName
end repeat
if cardId is 36080 then -- report format
put the short id of button "Type" into itemId
write cardId&&itemID&&"PB Type"&return&(button
"Type")&theDelimiter to file fileName
end if
go next
end repeat
close file fileName
pop card
set the cantAbort of this stack to false
put saveLanguage into card field "Language"
allOn
unlock screen
unlock messages
end mouseUp
The handler builds a text file with one entry for each shared
background field and one for each unshared bg and card field. The
text for each field begins with a header line listing the id of the
card and the id of the field and ends with an end of record character
(numToChar(215)).
The following handler updates stack-resident help fields from a text
file in the above format:
on changeLanguage -- 04/25/01
global
alcoholTranslated,badDate,badDbError,barrelTranslated,bkgndAddError,bkgndIdError,bottleLotTranslated,calculatorHelp,cancelMessage
global
cancelTranslated,cardDeleteError,cardIdError,changeMessage,dbError,Documents,duplicateError,firstCardError,gimmieTime,homeHelp,lastCardError
global
lotTranslated,myLanguage,noColon,noRecordError,numbersOnly,noTranslated,okTranslated,pressTranslated,productTranslated
global
rackTranslated,requiredField,receivedGrapesTranslated,receivedWineTranslated,tankTranslated,tooLongError,yesTranslated
put numToChar(215) into theDelimiter
get stripBlanks(the selectedText of button "Language")
put "("&it&")" into newLanguage
put myFolder()&"Oenotes"&&newLanguage into folderName
--put ":Oenotes"&&newLanguage into folderName
put folderName&":OeHelp"&&newLanguage&".txt" into fileName
if there is a folder folderName then
put Documents into saveDocuments
put folderName&":" into Documents -- overrides Hypercard's search
if there is a file fileName then
put it into card field "Language"
put newLanguage into myLanguage
open file fileName
lock screen
lock messages
push card
go first
set the cantModify of this stack to false
set the sharedText of field "Expired Shutdown Prompt Help" to true
put field "Expired Shutdown Prompt Help" into encryption
set the sharedText of field "Expired Shutdown Prompt Help" to false
pop card
push card
repeat
read from file fileName until theDelimiter
if it is empty then exit repeat
set cursor to busy
put word 1 of it into cardId
if cardId is not a number then answer cardIdError&&cardid
put word 2 of it into partId
put word 3 of it into partType
put line 1 of it into partName
delete line 1 of it
delete the last char of it -- the delimiter
delete the last char of it -- added return
if the short id of this card is not cardId then go to card id cardId
if partType is "BF" then
delete word 1 to 3 of partName
if partName is not in "Title,Index Title" then put it into
field id partId
else put it into line 2 of field id partId
else if partType is "CF" then
if cardId is 3978 and partId is 6 and encryption is not
empty then put the last word of card field id partId into the last
word of it
put it into card field id partId
if cardId is 4706 and partId is 56 then -- 56 = last help
field on Main Menu
put card field "Alcohol Translation Field Help" into
alcoholTranslated
put card field "Bad Date Field Help" into badDate
put card field "Bad DB Field Help" into badDbError
put card field "Barrel Translation Field Help" into
barrelTranslated
put card field "BG Add Field Help" into bkgndAddError
put card field "Bottle Lot Translation Field Help" into
bottleLotTranslated
put card field "Calculator Field Help" into calculatorHelp
put card field "Cancel Field Help" into cancelMessage
put card field "Cancel Translation Field Help" into
cancelTranslated
put card field "Card Delete Field Help" into cardDeleteError
put card field "Change Field Help" into changeMessage
put card field "DbError Field Help" into dbError
put card field "Duplicate Key Field Help" into duplicateError
put card field "First Record Field Help" into firstCardError
put card field "GimmieTime Field Help" into gimmieTime
put card field "Home Field Help" into homeHelp
put card field "Last Record Field Help" into lastCardError
put card field "Wine Lot Translation Field Help" into lotTranslated
put card field "No BG Field Help" into bkgndIdError
put card field "No Card Field Help" into cardIdError
put card field "No Colon Field Help" into noColon
put card field "No Record Field Help" into noRecordError
put card field "Numbers Only Field Help" into numbersOnly
put card field "OK Translation Field Help" into okTranslated
put card field "No Translation Field Help" into noTranslated
put card field "Press Translation Field Help" into pressTranslated
put card field "Product Translation Field Help" into
productTranslated
put card field "Rack Translation Field Help" into rackTranslated
put card field "RequiredField Field Help" into requiredField
put card field "Delivery (G) Translation Field Help" into
receivedGrapesTranslated
put card field "Delivery (W) Translation Field Help" into
receivedWineTranslated
put card field "Tank Translation Field Help" into tankTranslated
put card field "Too Big Field Help" into tooLongError
put card field "Yes Translation Field Help" into yesTranslated
end if
else put it into button "Type"
end repeat
set cursor to watch
close file fileName
pop card
unlock messages
unlock screen
doMenu "Compact Stack"
set the cantModify of this stack to true
else
put saveDocuments into Documents
ohOh
answer card field "Can't Find Help"&&fileName&"!"
end if
else
ohOh
answer card field "Can't Find Help"&&folderName&"!"
end if
end changeLanguage
--
Rob Cozens
CCW, Serendipity Software Company
http://www.oenolog.com/who.htm
"And I, which was two fooles, do so grow three;
Who are a little wise, the best fooles bee."
from "The Triple Foole" by John Donne (1572-1631)
More information about the use-livecode
mailing list