Re: Applescript localization support
Re: Applescript localization support
- Subject: Re: Applescript localization support
- From: "Mark J. Reed" <email@hidden>
- Date: Tue, 24 Jun 2008 08:27:01 -0400
You cannot include the Chinese characters in the AppleScript code in
AS 1.x. Full stop. If you see Chinese in the source code, it will
not work. You have to put the Chinese in a separate file. See Chris's
message about how to use "localized string" to do this more easily..
On 6/24/08, parag vibhute <email@hidden> wrote:
> Hi Philip,
>
> Yes u r right that I want to send an email with chinese language content and
> ofcourse it will work fine on Leopard because Leopard has Applescript 2.0
> which supports unicode character set. But this script will not work in
> Panther & Tiger. When you compile it, chinese characters will be garbled.
>
> Regarding your second point: The script with given posix path works fine.
>
> Thanks,
> Palav
>
> On Tue, Jun 24, 2008 at 3:49 PM, Philip Aker <email@hidden> wrote:
>
>> Parag,
>>
>> If I understand your problem correctly, you want to send an email with
>> Chinese language content. This works for me on 10.5.3 with the characters
>> you have supplied:
>> set *chinese_body* to "*状*态" as Unicode text
>> tell application "*Mail*"
>> set *theMessage* to make new outgoing message with properties {visible:
>> true, subject:"*My Subject*", content:*chinese_body*}
>> tell *theMessage*
>> make new to recipient at end of to recipients with properties {address:"*
>> email@hidden*"}
>> end tell
>> end tell
>>
>> I see below you have to accommodate for Tiger by loading an attachment but
>> it's not clear to me that "POSIX path of "/status.zip" is going to work. I
>> think you need a file reference for attachments. Look in
>> "/Library/Scripts/Mail Scripts" for an example of how to create a message
>> with an attachment.
>>
>>
>>
>> On 08-06-24, at 01:30, parag vibhute wrote:
>>
>> Thanks for reply.
>>
>> I tried same thing (only difference is I tried this through Cocoa
>> application i.e. creating localizable.string file etc.)
>>
>> Following is the script which was printed via NSLog:
>>
>> with timeout of 30 seconds
>> set theAttachment to POSIX path of "/status.zip"
>> tell application "Mail"
>> set theMessage to make new outgoing message with properties {visible:true,
>> subject:"Test", content:"
>>
>> 状态
>>
>> "}
>> tell content of theMessage
>> make new attachment with properties {file name:theAttachment} at after
>> last
>> paragraph
>>
>> end tell
>> end tell
>> end timeout
>>
>>
>> But I am getting following error which I am unable to understand
>> {
>> NSAppleScriptErrorBriefMessage =
>> "\U9810\U671f\U7684\U662f\Ufffd\"\U8342A\U4f46\U627e\U5230\U7684\U662f\U5de5\U5e8f\U6307\U4ee4\U7d50\U5c3e\U3002";
>>
>> NSAppleScriptErrorMessage =
>> "\U9810\U671f\U7684\U662f\Ufffd\"\U8342A\U4f46\U627e\U5230\U7684\U662f\U5de5\U5e8f\U6307\U4ee4\U7d50\U5c3e\U3002";
>>
>> NSAppleScriptErrorNumber = -2741;
>> NSAppleScriptErrorRange = <b0010000 00000000 >;
>> }
>>
>>
>> Can you tell what is the error & what should be the solution?
>>
>> Thanks,
>> Palav
>>
>> On Tue, Jun 24, 2008 at 5:56 AM, Christopher Nebel <email@hidden>
>> wrote:
>> AppleScript 2.0 added support for literal Unicode strings in the source
>> code, but that's not necessary for your problem. What you want is the
>> "localized string" command. Using it is a little complicated, but not too
>> bad:
>>
>> 1. Save your script as a bundle (ideally an application bundle, but a
>> script bundle should work as well).
>> 2. For any text you want to localize, replace the literal string with a
>> function call, like this:
>>
>> localized string "My Body"
>>
>> 3. In the script bundle resources, make a new lproj folder named for the
>> locale you want -- for example, "zh_CN.lproj" for Chinese. Inside that,
>> add
>> a text file named "Localizable.strings", which contains lines like this:
>>
>> "My Body" = "Chinese My Body";
>>
>> Save them as UTF-16; TextEdit should do that for you if necessary. Repeat
>> as necessary for all the strings and all the locales you want. When you
>> run
>> the script, the "localized string" calls will return the localized string
>> that you provided. (If someone tries to use a locale you didn't provide
>> text for, it will return the original string, so it's wise to make them at
>> least somewhat readable.)
>>
>>
>> --Chris Nebel
>> AppleScript Engineering
>>
>>
>> On Jun 23, 2008, at 5:21 AM, parag vibhute wrote:
>>
>> Any answer guys???
>>
>> I know Applescript 2.0 (which run on Leopard) supports unicode character
>> set & so support chinese language localization. But what about panther &
>> tiger? It(script with chinese string) does not give expected output on
>> Panther & tiger. So what should be the solution?
>>
>> Thanks,
>> Palav
>>
>> On Mon, Jun 16, 2008 at 6:37 PM, parag vibhute <email@hidden>
>> wrote:
>>
>> I have following script for generating an email in Apple Mail application:
>>
>> tell application "Mail"
>> set theMessage to make new outgoing message with properties
>> {visible:true, subject:"My Subject", content:"My Body"}
>> tell theMessage
>> make new to recipient at end of to recipients with properties
>> {address:"email@hidden"}
>> end tell
>> end tell
>>
>> Now I want to make content of email("My Body" in above script) in Chinese
>> language instead of English, how can I do it? I tried in script editor but
>> whenever I compile the script chinese characters gets changed to some
>> garbage character. What should I do?
>>
>>
>> Philip Aker
>> echo email@hidden@nl | tr a-z@. p-za-o.@
>>
>> Democracy: Two wolves and a sheep voting on lunch.
>>
>>
>
>
> --
>
> There are many things in your life that will catch your eye but only a few
> will catch your heart....pursue those'.
>
--
Sent from Gmail for mobile | mobile.google.com
Mark J. Reed <email@hidden>
_______________________________________________
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