As part of the switch, about 370 text items (with a total of less than 150 kilobytes) are replaced with text from the other language.
If I run the stack on pre 7.0 versions of LC, the function takes less than a second.
On LC 7.0 (dp5) the process takes about 50 seconds (sometimes a few seconds more, sometimes a few seconds less)!!
This in on Windows 7 Prof, on an i7-2720 QM processor with plenty of RAM.
Here is the code of the function.
Code: Select all
#-----------------------------------------------------------------
# Input: Language supported by this app
# Output: Language
#-----------------------------------------------------------------
function changeLanguage thisLanguage
set itemDelimiter to "|"
local tCardName
local tLCategories, tUCategories
local tLQuotes, tUQuotes
local tID
local tLine
local tText
local tStartTime, tEndTime
put the milliseconds into tStartTime
put "Language" & thisLanguage into tCardName
if thisLanguage <> "English" then
put field "itemList" of card tCardName of stack "EQLanguages" into gLocalizedItems
else
put empty into gLocalizedItems
end if
put field "CategoriesList" of card tCardName of stack "EQLanguages" into tLCategories
put field "QuotesList" of card tCardName of stack "EQLanguages" into tLQuotes
put field "CategoriesList" of card "QuotesSettings" of stack "EQUserdata" into tUCategories
put field "QuotesList" of card "QuotesSettings" of stack "EQUserdata" into tUQuotes
# simply transfer items for categories as there are no user-defined items
# alltogether 10 lines of text
put 0 into tLine
repeat for each line thisLine in tLCategories
add 1 to tLine
put item 2 of thisLine into item 2 of line tLine of tUCategories
end repeat
# make sure to only transfer application-defined items and leave user-defined items alone
# alltogether 360 lines of quotes
repeat for each line thisLine in tLQuotes
put item 1 of thisLine into tID
put lineOffset(tID, tUQuotes) into tLine
put item 2 of thisLine into item 2 of line tLine of tUQuotes
end repeat
put tUCategories into field "CategoriesList" of card "QuotesSettings" of stack "EQUserdata"
put tUQuotes into field "QuotesList" of card "QuotesSettings" of stack "EQUserdata"
put thisLanguage into gLanguage
set the EQLanguage of stack "EQUserdata" to thisLanguage
put the milliseconds into tEndTime
answer "The function took " & (tEndTime - tStartTime) & " milliseconds"
return thisLanguage
end changeLanguage
The massive slowness of this functionality on LC 7.0 is really scary - it would be prohibitive for using it live.