Here’s a little script I just made.
set toolbarItems to {}
repeat
display dialog "Make toolbar item based on this name:" default answer "" buttons {"Done", "Repeat"} default button 2
if (button returned of result) is "Done" then
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ASCII character 10}
set the clipboard to (toolbarItems as text)
set AppleScript's text item delimiters to ASTID
exit repeat
else
get text returned of result
set toolbarItems's end to ¬
("make new toolbar item at end of toolbar items with properties {" & ¬
"identifier:\"" & result & " ID\", " & ¬
"name:\"" & (words of result as text) & "\", " & ¬
"label:\"" & result & "\", " & ¬
"palette label:\"" & result & "\", " & ¬
"tool tip:\"" & result & "\"}")
end if
end repeat
beep
Added option to read list of phrases from text file:
set toolbarItems to {}
repeat
display dialog "Make toolbar item based on this name:" default answer "" buttons {"Read from file.", "Done", "Repeat"} default button 3
if (button returned of result) is "Done" then
done(toolbarItems)
exit repeat
else if (button returned of result) is "Read from file." then
choose file without invisibles
do shell script "cat " & quoted form of POSIX path of result
get paragraphs of result
repeat with thisText in result
set toolbarItems's end to generateToolbarItemCode(thisText)
end repeat
done(toolbarItems)
exit repeat
else
set end of toolbarItems to generateToolbarItemCode(text returned of result)
end if
end repeat
beep
on generateToolbarItemCode(theText)
return ¬
("make new toolbar item at end of toolbar items with properties {" & ¬
"identifier:\"" & theText & " ID\", " & ¬
"name:\"" & (do shell script "echo " & quoted form of (words of theText as text) & " | ruby -n -e 'print $_.downcase'") & "\", " & ¬
"label:\"" & theText & "\", " & ¬
"palette label:\"" & theText & "\"}")
end generateToolbarItemCode
on done(theList)
set ASTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to ASCII character 10
set the clipboard to (theList as text)
set AppleScript's text item delimiters to ASTID
return true
end done