AppleScript名:指定言語環境(Locale)の月名、曜日名を取得する |
use AppleScript version "2.4" use scripting additions use framework "Foundation" set aList to getLocalizedDaynames("en_US") –> {"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"} set aList to getLocalizedDaynames("fr_FR") –> {"Dimanche", "Lundi", "Mardi", "Mercredi", "Jeudi", "Vendredi", "Samedi"} set aList to getLocalizedDaynames("ja_JP") –> {"日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日"} set aList to getLocalizedDaynames("zh-Hans") –> {"星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"} set bList to getLocalizedMonthnames("en_US") –> {"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"} set bList to getLocalizedMonthnames("fr_FR") –> {"janvier", "février", "mars", "avril", "mai", "juin", "juillet", "août", "septembre", "octobre", "novembre", "décembre"} set bList to getLocalizedMonthnames("ja_JP") –> {"1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"} set bList to getLocalizedMonthnames("zh-Hans") –> {"一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"} –ローカライズされた曜日名称を返す on getLocalizedDaynames(aLoc) set df to current application’s NSDateFormatter’s alloc()’s init() df’s setLocale:(current application’s NSLocale’s localeWithLocaleIdentifier:aLoc) set dayNames to df’s standaloneWeekdaySymbols() as list return dayNames end getLocalizedDaynames –ローカライズされた月名称を返す on getLocalizedMonthnames(aLoc) set df to current application’s NSDateFormatter’s alloc()’s init() df’s setLocale:(current application’s NSLocale’s localeWithLocaleIdentifier:aLoc) set monthNames to df’s standaloneMonthSymbols() as list return monthNames end getLocalizedMonthnames |
More from my site
(Visited 68 times, 1 visits today)
Keynoteの最前面のドキュメントの現在のスライドに指定月の日曜日はじまりカレンダーを表で作成 – AppleScriptの穴 says:
[…] 国、その現場ごとのルールに合わせて変更することが重要です。曜日名についても、実行中のユーザーの言語環境から取得して入れることも可能なので、そのようにしてもよいでしょう。 […]