Search code examples
macoslocalizationapplescriptlocalizable.stringsapplescript-objc

Why applescript doesn't accept file object in localized string command?


Following applescript throws error:

set thePath to path to application support from user domain as alias
set mystr to localized string "Add people to this note" in bundle file thePath

And the error is

error "Can’t make file (alias \"Macintosh HD:Users:shakes:Library:Application Support:\") into type file." number -1700 from file (alias "Macintosh HD:Users:shakes:Library:Application Support:") to file

What does this error means? localized string expects a file or alias object which thePath is then why this error?

FYI, localized string reference says:

Syntax
localized   string  text    required
from table   text   optional
in bundle   fileSpecifier   optional

Solution

  • The folder Application Support is not a file. Remove the file keyword.

    set thePath to path to application support from user domain -- as alias is redundant
    set mystr to localized string "Add people to this note" in bundle thePath
    

    But the code is meaningless because the folder Application Support is not a bundle either.