I'm trying to use the command 'localized string' in Applescript
Studio 1.4, Xcode 2.3.
I've added a strings file to my bundle as "Contents/Resources/
English.lproj/Localizable.strings" saved in UTF-16 and formatted as:
/* Gadgets */
"Yes" = "foo";
"No" = "bar";
If I ask for the localized string "Yes" with 'display alert (get
localized string "Yes")' then "Yes" is returned. If I ask for a
localized string "Maybe" that isn't in the strings file the command
returns "Maybe" regardless. If I ask the command to search a
strings file that doesn't exist with 'display alert (get localized
string "Yes" from table "foobar")' it returns "Yes" with no errors.
Now this is the icing on the cake, if I ask 'display alert (get
localized string (1+1))' it returns "2".
What am I doing wrong?
The only one of those that's actually wrong is the first one.
"localized string" is defined to return the input string if there is
no localized version to be found, and that includes not being found
because the table was missing. (The reason the last one works the
way it does is that that's what you told it to do: it evaluated (1
+1), came up with 2, and coerced that to a string.)
Why your Localizable.strings file isn't kicking in is a bit of a
mystery to me, given what you've said so far. You might check the
built product to make sure that the file is in the right place.
Incidentally, Xcode has explicit support for localized resources --
see the "Make File Localizable" button in the Info window. If you're
not using that, you're making life harder for yourself.