Re. third-party dependencies [was Re: Stock Quotes using AppleScript]
Re. third-party dependencies [was Re: Stock Quotes using AppleScript]
- Subject: Re. third-party dependencies [was Re: Stock Quotes using AppleScript]
- From: KOENIG Yvan <email@hidden>
- Date: Mon, 16 Mar 2009 22:45:34 +0100
Here is the code returning the correct localized functions name even
if the iWork 's app is not using the same language than the operating
system to display its GUI.
--[SCRIPT]
property theApp : "Numbers"
--=====
on run
set p2lproj to my getlprojPath(theApp)
set ISBLANK_loc to my getLocalizedFuncName(p2lproj, "ISBLANK")
set VLOOKUP_loc to my getLocalizedFuncName(p2lproj, "VLOOKUP")
end run
--=====
on decoupe(t, d)
local l
set AppleScript's text item delimiters to d
set l to text items of t
set AppleScript's text item delimiters to ""
return l
end decoupe
--=====
on getLocalizedFuncName(f, x)
return localized string x from table "Localizable" in bundle file f
end getLocalizedFuncName
--=====
on getlprojPath(aa)
local lprojs, localId, lproj
set lprojs to {{"da_DK", "da"}, {"nl_NL", "Dutch"}, {"en_US",
"English"}, {"fi_FI", "fi"}, {"fr_FR", "French"}, {"de_DE",
"German"}, {"it_IT", "Italian"}, {"ja_JP", "Japanese"}, {"ko_KR",
"ko"}, {"no_NO", "no"}, {"pl_PL", "pl"}, {"pt_BR", "pt"}, {"pt_PT",
"pt_PT"}, {"ru_RU", "ru"}, {"es_ES", "Spanish"}, {"sv_SE", "sv"},
{"zf_CN", "zh_CN"}, {"zh_TW", "zh_TW"}}
if aa starts with "Pages" then (* why are they using different
strings ? *)
tell application aa to set localId to localized string "http://
support.apple.com/manuals/#iwork"
else (* here for Keynote or Numbers *)
tell application aa to set localId to localized string "http://
support.apple.com/en_US/manuals/#iwork"
end if (*
in French, the local string is "http://support.apple.com/fr_FR/
manuals/#iwork"
in English, if theApp is Pages, it is "http://support.apple.com/
manuals/#iwork"*)
set localId to my decoupe(localId, "/")
if (count of localId) = 5 then
set localId to "English"
else
set localId to item 4 of localId
end if
set lproj to ""
repeat with i from 1 to count of lprojs
if localId is item 1 of item i of lprojs then
set lproj to item 2 of item i of lprojs
exit repeat
end if
end repeat
if lproj = "" then
if my parleFrancais() then
error "Le fichier FrameWorks " & localId & " manque !"
else
error "The Frameworks file " & localId & "is missing !"
end if
else
return (path to application support as text) & "iWork
'09:Frameworks:SFTabular.framework:Versions:A:Resources:" & lproj &
".lproj"
end if
(* Given the language used to display the program's GUI, lproj is:
da, Dutch, English, fi, French, German, Italian, Japanese, ko, no,
pl, pt, pt_PT, ru, Spanish, sv, zh_CN, zh_TW
*)
end getlprojPath
--=====
--[/SCRIPT]
Yvan KOENIG (from FRANCE Monday, March 16, 2009 22:40:23)
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden