AppleScript名:DIctionary.appの辞書名を言語で抽出 |
— Created 2015-10-25 by Takaaki Naganoya — 2015 Piyomaru Software use AppleScript version "2.4" use scripting additions use framework "Foundation" use framework "dictKit" –https://github.com/mattt/DictionaryKit –Dictionary.appのすべての辞書名を出力 set d1Res to getEveryLocalDictionaryInformation() of me –> {{dictName:"뉴에이스 영한사전 / 뉴에이스 한영사전", dictLang:"韓国語 – 英語"}, {dictName:"Multidictionnaire de la langue française", dictLang:"フランス語"}, {dictName:"राजपाल हिन्दी शब्दकोश", dictLang:"ヒンディー語"}, ….} –DIctionary.appの辞書のうち言語ラベル(shortName)が「日本語」ではじまるものを抽出(和英辞典など) set d2Res to getLocalDictionaryInformationByFromLang("日本語") of me –> {{dictName:"スーパー大辞林", dictLang:"日本語"}, {dictName:"ウィズダム英和辞典 / ウィズダム和英辞典", dictLang:"日本語 – 英語"}} –Dictionary.appの辞書のうち言語ラベル(shortName)が「日本語」で終わるものを抽出(英和辞典、日本語辞典) set d3Res to getLocalDictionaryInformationByToLang("日本語") of me –> {{dictName:"スーパー大辞林", dictLang:"日本語"}} –Dictionary.appの辞書のうち言語ラベル(shortName)が「日本語」ではじまり「英語」で終わるもの(和英辞典)を抽出 set d4Res to getLocalDictionaryInformationByFromToLang("日本語", "英語") of me –> {{dictName:"ウィズダム英和辞典 / ウィズダム和英辞典", dictLang:"日本語 – 英語"}} on getEveryLocalDictionaryInformation() set dSet to current application’s TTTDictionary’s availableDictionaries() set dList to dSet’s allObjects() set dNameList to {} repeat with i in dList set aName to (|name|() of i) as string set sName to (shortName() of i) as string set the end of dNameList to {dictName:aName, dictLang:sName} end repeat return dNameList end getEveryLocalDictionaryInformation on getLocalDictionaryInformationByFromLang(aFromLang) set dSet to current application’s TTTDictionary’s availableDictionaries() set dList to dSet’s allObjects() set dNameList to {} repeat with i in dList set aName to (|name|() of i) as string set sName to (shortName() of i) as string if sName begins with aFromLang then set the end of dNameList to {dictName:aName, dictLang:sName} end if end repeat return dNameList end getLocalDictionaryInformationByFromLang on getLocalDictionaryInformationByToLang(aToLang) set dSet to current application’s TTTDictionary’s availableDictionaries() set dList to dSet’s allObjects() set dNameList to {} repeat with i in dList set aName to (|name|() of i) as string set sName to (shortName() of i) as string if sName ends with aToLang then set the end of dNameList to {dictName:aName, dictLang:sName} end if end repeat return dNameList end getLocalDictionaryInformationByToLang on getLocalDictionaryInformationByFromToLang(aFromLang, aToLang) set dSet to current application’s TTTDictionary’s availableDictionaries() set dList to dSet’s allObjects() set dNameList to {} repeat with i in dList set aName to (|name|() of i) as string set sName to (shortName() of i) as string if sName starts with aFromLang and sName ends with aToLang then set the end of dNameList to {dictName:aName, dictLang:sName} end if end repeat return dNameList end getLocalDictionaryInformationByFromToLang |
More from my site
(Visited 73 times, 1 visits today)