Re: Localized Internals of AppleScript (date Class for example)
Re: Localized Internals of AppleScript (date Class for example)
- Subject: Re: Localized Internals of AppleScript (date Class for example)
- From: kai <email@hidden>
- Date: Sun, 17 Apr 2005 20:49:19 +0100
On Sun, 17 Apr 2005 01:52:55 +0200, Brian wrote:
Le 15 avr. 05, à 19:09, Paul Berkowitz a écrit :
What would be useful would be some sort of 'as local text' coercion:
weekday of someDate
--> Thursday
weekday of someDate as local text
--> "jeudi"
Thursday as local text
--> "jeudi"
Totally agree with you Paul, that would be the better solution.
In waiting for that, I made an ugly script that try to translate
constant in the 'local language'.
It works with several languages / custom settings, but not with the
ones that requires an Unicode application...
[snip: script]
I believe there's an issue (at least in this context) with the standard
settings for Brazil and Portugal, where weekdays are not normally
included in a date string. (They could, of course, be added by
customising those particular settings.) In addition, custom settings
that differ substantially from the default for any country might also
cause problems.
Remember : I say ugly... but it works (here...).
It takes a month or a weekday constant as parameter and return the
local translation as a string.
Just change your settings in the "International" preference panel to
play with it. You will have to call the
initTranslation () command after you change settings, because the
translations are in properties.
Because of it's length, I was searching a way to call it from another
script and...
[snip: more script]
It should be possible to achieve something similar with slightly less
code, Brian. For example:
----------------
on localWeekday(w)
repeat with n in "1234567"
tell date n to if its weekday is w then tell date string
tell word 1 to if (count) > 2 then
return it
else if it contains n then
return w as string -- no translation
end if
return word 2
end tell
end repeat
end localWeekday
localWeekday(Monday)
--> "mandag" (International/Date set to: Denmark)
----------------
on localMonth(m)
set d to date (1 as string)
set d's month to m
set d to d's date string
tell d's word -2 to if (count) > 2 then return it
d's word -3
end localMonth
localMonth(April)
--> "huhtikuu" (International/Date set to: Finland)
----------------
I guess strftime might help to resolve the couple of non-translation
cases, if anyone has any experience there...
---
kai
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Applescript-users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden