Mailing Lists: Apple Mailing Lists

Image of Mac OS face in stamp
 
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: localized string returns input string



On Jun 8, 2006, at 2:44 PM, Daniel Pimley wrote:

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.


--Chris Nebel AppleScript Engineering

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-studio mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/applescript-studio/email@hidden

This email sent to email@hidden
References: 
 >localized string returns input string (From: Daniel Pimley <email@hidden>)



Visit the Apple Store online or at retail locations.
1-800-MY-APPLE

Contact Apple | Terms of Use | Privacy Policy

Copyright © 2007 Apple Inc. All rights reserved.