Menu

Skip to content
AppleScriptの穴
  • Home
  • Products
  • Books
  • Docs
  • Events
  • Forum
  • About This Blog
  • License
  • 仕事依頼

AppleScriptの穴

Useful & Practical AppleScript archive. Click '★Click Here to Open This Script' Link to download each AppleScript

タグ: 10.11savvy

文字エンコーディングを自動判別してファイル読み込み v1.2.1

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:文字エンコーディングを自動判別してファイル読み込み v1.2.1
— Created 2014-12-28 by Takaaki Naganoya
— Modified 2014-12-29 by Shane Stanley
— Modified 2015-10-03 by Takaaki Naganoya
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"

set aPath to POSIX path of (choose file)
set aRes to readJapanesTextFileWithGuessingEncoding(aPath) of me
set bRes to aRes as string

–Read Japanese text with detecting its text encoding
on readJapanesTextFileWithGuessingEncoding(aPOSIXpath as string)
  
  
–ISO2022JP check
  
set aNSData to current application’s NSData’s dataWithContentsOfFile:aPOSIXpath
  
set aDataLength to aNSData’s |length|()
  
if aDataLength > 1024 then set aDataLength to 1024
  
  
–0x1B check
  
set anNSString to current application’s NSString’s stringWithString:(character id 27) — 0x1B
  
set theData to anNSString’s dataUsingEncoding:(current application’s NSUTF8StringEncoding)
  
set theRange to aNSData’s rangeOfData:theData options:0 range:(current application’s NSMakeRange(0, aDataLength))
  
  
–found 0x1B in aNSData
  
if |length| of theRange = 1 and location of theRange < aDataLength then
    set aStr to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSISO2022JPStringEncoding)) –21
    
if aStr is not equal to missing value then return (aStr as text) — ISO2022JP
  end if
  
  
–EUC
  
set resValue to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSJapaneseEUCStringEncoding))
  
–log resValue
  
if resValue is not equal to missing value then return (resValue as text)
  
–UTF-8
  
set resValue to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSUTF8StringEncoding))
  
–log resValue
  
if resValue is not equal to missing value then return (resValue as text)
  
–SHift JIS
  
set resValue to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSShiftJISStringEncoding))
  
–log resValue
  
if resValue is not equal to missing value then return (resValue as text)
  
  
  
–UTF-16BE/LE/無印Unicodeは多数決を取る
  
set resValue1 to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSUTF16BigEndianStringEncoding)) as text
  
–log resValue1
  
set sample1 to getTextSample(resValue1) of me
  
set lang1 to specifyLanguageOfText(sample1) of me
  
set para1 to length of (paragraphs of sample1)
  
set words1 to length of (words of sample1)
  
  
set resValue2 to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSUTF16LittleEndianStringEncoding)) as text
  
–log resValue2
  
set sample2 to getTextSample(resValue2) of me
  
set lang2 to specifyLanguageOfText(sample2) of me
  
set para2 to length of (paragraphs of sample2)
  
set words2 to length of (words of sample2)
  
  
set resValue3 to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSUnicodeStringEncoding)) as text
  
–log resValue3
  
set sample3 to getTextSample(resValue3) of me
  
set lang3 to specifyLanguageOfText(sample3) of me
  
set para3 to length of (paragraphs of sample3)
  
set words3 to length of (words of sample3)
  
  
–文字および文法的に見て「日本語」ならそれを返す
  
if lang1 = "ja" then return resValue1
  
if lang2 = "ja" then return resValue2
  
if lang3 = "ja" then return resValue2
  
  
  
–文字化けしたときには、日本語の「Word」として認識されづらく、Paragraphも少ない(1とか)なので条件で除外する
  
if para1 is not equal to 1 then
    if (words1 ≤ words2) or (words1 ≤ words3) then
      return resValue1
    end if
  end if
  
  
if para2 is not equal to 1 then
    if (words2 ≤ words1) or (words2 ≤ words3) then
      return resValue2
    end if
  end if
  
  
if para3 is not equal to 1 then
    if (words3 ≤ words1) or (words3 ≤ words2) then
      return resValue3
    end if
  end if
  
  
return false
  
  
(*
  –おまけ(未確認)
  set resValue to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSWindowsCP1251StringEncoding))
  if resValue is not equal to missing value then return resValue
  
  set resValue to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSWindowsCP1252StringEncoding))
  if resValue is not equal to missing value then return resValue
  
  set resValue to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSWindowsCP1253StringEncoding))
  if resValue is not equal to missing value then return resValue
  
  set resValue to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSWindowsCP1254StringEncoding))
  if resValue is not equal to missing value then return resValue
  
  set resValue to (current application’s NSString’s alloc()’s initWithData:aNSData encoding:(current application’s NSWindowsCP1250StringEncoding))
  if resValue is not equal to missing value then return resValue
  
  return false
  *)

end readJapanesTextFileWithGuessingEncoding

on specifyLanguageOfText(aStr)
  set aNSstring to current application’s NSString’s stringWithString:aStr
  
set tagSchemes to current application’s NSArray’s arrayWithObjects:(current application’s NSLinguisticTagSchemeLanguage)
  
set tagger to current application’s NSLinguisticTagger’s alloc()’s initWithTagSchemes:tagSchemes options:0
  
tagger’s setString:aNSstring
  
set aLanguage to tagger’s tagAtIndex:0 |scheme|:(current application’s NSLinguisticTagSchemeLanguage) tokenRange:(missing value) sentenceRange:(missing value)
  
return aLanguage as text
end specifyLanguageOfText

on getTextSample(aText)
  set aLen to length of aText
  
if aLen < 1024 then
    set bLen to aLen
  else
    set bLen to 1024
  end if
  
return (text 1 thru bLen of aText)
end getTextSample

★Click Here to Open This Script 

Posted in Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

なろう系ルビタグを置換

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:なろう系ルビタグを置換
— Created 2018-01-14 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
–http://piyocast.com/as/archives/5117

property NSString : a reference to current application’s NSString
property NSScanner : a reference to current application’s NSScanner
property NSMutableArray : a reference to current application’s NSMutableArray
property NSRegularExpressionSearch : a reference to current application’s NSRegularExpressionSearch
property NSNumberFormatterRoundUp : a reference to current application’s NSNumberFormatterRoundUp

set aStr to " 数多国ある西方諸国だが、元を辿ればとある一つの国へとつながっていた。それは幻晶騎士(シルエットナイト)の力により西方の地に覇をとなえた人類が作り上げた超巨大国家、その名を“ファダーアバーデン”という。
 西方暦一二八九年の現在において西方諸国を構成する主要国家、“ジャロウデク王国”、“クシェペルカ王国”、“ロカール諸国連合”、“|孤独なる十一《イレブンフラッグス》”などの国々は、全てかの巨大国家が分裂してできた残滓なのである。"

–set aStr to getEditorText()

–"|○o○o○《XXXXX》" –> "XXXXX"
set bRes to trimStrHeaderFromTo(aStr, "|", "《", "》") of me

–"aaaaa○○○(XXXXX)" –> "XXXXX"
set cStr to trimStrHeaderFromToForward(bRes, "(", ")") of me

(*
" 数多国ある西方諸国だが、元を辿ればとある一つの国へとつながっていた。それはシルエットナイトの力により西方の地に覇をとなえた人類が作り上げた超巨大国家、その名を“ファダーアバーデン”という。
 西方暦一二八九年の現在において西方諸国を構成する主要国家、“ジャロウデク王国”、“クシェペルカ王国”、“ロカール諸国連合”、“イレブンフラッグス”などの国々は、全てかの巨大国家が分裂してできた残滓なのである。"
*)

–"|○o○o○《XXXXX》" –> "XXXXX"
on trimStrHeaderFromTo(aParamStr, headerStr, fromStr, toStr)
  set theScanner to NSScanner’s scannerWithString:aParamStr
  
set anArray to NSMutableArray’s array()
  
  
repeat until (theScanner’s isAtEnd as boolean)
    set {theResult, theKey} to theScanner’s scanUpToString:headerStr intoString:(reference)
    
    
theScanner’s scanString:fromStr intoString:(missing value)
    
set {theResult, theValue} to theScanner’s scanUpToString:fromStr intoString:(reference)
    
if theValue is missing value then set theValue to ""
    
    
theScanner’s scanString:fromStr intoString:(missing value)
    
    
anArray’s addObject:theValue
  end repeat
  
  
if anArray’s |count|() = 0 then return aParamStr
  
  
copy aParamStr to curStr
  
repeat with i in (anArray as list)
    set curStr to repChar(curStr, i & fromStr, "") of me
  end repeat
  
  
set curStr to repChar(curStr, toStr, "") of me
  
  
return curStr
end trimStrHeaderFromTo

–"aaaaa○○○(XXXXX)" –> "XXXXX"
on trimStrHeaderFromToForward(aParamStr, fromStr, toStr)
  set theScanner to NSScanner’s scannerWithString:aParamStr
  
set anArray to NSMutableArray’s array()
  
  
repeat until (theScanner’s isAtEnd as boolean)
    set {theResult, theKey} to theScanner’s scanUpToString:fromStr intoString:(reference)
    
set curLoc to (theScanner’s scanLocation()) + 1
    
    
–scan back to different kind of character
    
set prevKind to detectCharKindMain(text (curLoc – 1) of aParamStr) of me
    
    
repeat with i from curLoc – 2 to 1 by -1
      set aStr to text i of aParamStr
      
set curKind to detectCharKindMain(aStr) of me
      
      
if prevKind is not equal to curKind then
        exit repeat
      end if
    end repeat
    
    
try
      set tmpStr to text (i + 1) thru curLoc of aParamStr
      
theScanner’s scanString:fromStr intoString:(missing value)
      
set {theResult, theValue} to theScanner’s scanUpToString:fromStr intoString:(reference)
      
if theValue is missing value then set theValue to ""
      
      
theScanner’s scanString:fromStr intoString:(missing value)
      
      
anArray’s addObject:tmpStr
    end try
    
  end repeat
  
  
if anArray’s |count|() = 0 then return aParamStr
  
  
copy aParamStr to curStr
  
repeat with i in (anArray as list)
    set curStr to repChar(curStr, i, "") of me
  end repeat
  
  
set curStr to repChar(curStr, toStr, "") of me
  
  
return curStr
end trimStrHeaderFromToForward

on repChar(aStr, targStr, repStr)
  set aString to current application’s NSString’s stringWithString:aStr
  
set bString to aString’s stringByReplacingOccurrencesOfString:targStr withString:repStr
  
set cString to bString as string
  
return cString
end repChar

–文字種別判定
on detectCharKindMain(aStr)
  set s1Res to chkKanji(aStr) of me
  
set s2Res to chkKatakana(aStr) of me
  
set s3Res to chkHiragana(aStr) of me
  
set s4Res to chkLineFeed(aStr) of me
  
set s5Res to chkSpecialSign(aStr) of me
  
set s6Res to chkAlphaNumeric(aStr)
  
  
if s1Res = true then
    set curKind to "Kanji"
  else if s2Res = true then
    set curKind to "Katakana"
  else if s3Res = true then
    set curKind to "Hiragana"
  else if s4Res = true then
    set curKind to "Line Feed"
  else if s5Res = true then
    set curKind to "Sign"
  else if s6Res = true then
    set curKind to "Alpha Numeric"
  end if
  
  
return curKind
end detectCharKindMain

on chkKanji(aChar)
  return detectCharKind(aChar, "[一-龠]") of me
end chkKanji

on chkHiragana(aChar)
  return detectCharKind(aChar, "[ぁ-ん]") of me
end chkHiragana

on chkKatakana(aChar)
  return detectCharKind(aChar, "[ァ-ヶ]") of me
end chkKatakana

on chkLineFeed(aChar)
  return aChar is in {string id 10, string id 13, string id 13 & string id 10}
end chkLineFeed

on chkSpecialSign(aChar)
  return aChar is in {"「", "」", "『", "』", "ー", "―", "〜", "~", "!", "?", "&", "/", "《", "》", "#", "…", "・", "♪", "。", "、", ".", "々", "“", "”", "*", "(", ")", "(", ")", " ", " ", "§", "【", "】", "■", "%", "≒"}
end chkSpecialSign

on chkAlphaNumeric(aChar)
  return detectCharKind(aChar, "[a-zA-Z0-9a-zA-Z0-9]") of me –半角全角英数字
end chkAlphaNumeric

on detectCharKind(aChar, aPattern)
  set aChar to NSString’s stringWithString:aChar
  
set searchStr to NSString’s stringWithString:aPattern
  
set matchRes to aChar’s rangeOfString:searchStr options:(NSRegularExpressionSearch)
  
if matchRes’s location() = (current application’s NSNotFound) or (matchRes’s location() as number) > 9.99999999E+8 then
    return false
  else
    return true
  end if
end detectCharKind

on getEditorText()
  tell application "CotEditor"
    if (count every document) = 0 then return false
    
tell front document
      return contents
    end tell
  end tell
end getEditorText

★Click Here to Open This Script 

Posted in Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

ASOCで英数字以外を削除して返す

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:ASOCで英数字以外を削除して返す
— Created 2015-12-02 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aStr to "<< 98158999992aazaaZZZ
>>"

set bStr to returnNumberAndAlphabetCharsOnly(aStr)
–>  "98158999992aazaaZZZ"

on returnNumberAndAlphabetCharsOnly(aStr)
  set anNSString to current application’s NSString’s stringWithString:aStr
  
set anNSString to anNSString’s stringByReplacingOccurrencesOfString:"[^0-9A-Za-z]" withString:"" options:(current application’s NSRegularExpressionSearch) range:{0, anNSString’s |length|()}
  
return anNSString as text
end returnNumberAndAlphabetCharsOnly

★Click Here to Open This Script 

Posted in Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

AlphabetとNumericの混在かどうかを調べる

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:AlphabetとNumericの混在かどうかを調べる
— Created 2015-12-04 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aRes to chkMixtureOfNumericAndAlphabet("ABC") of me
–>  false

set aRes to chkMixtureOfNumericAndAlphabet("123") of me
–>  false

set aRes to chkMixtureOfNumericAndAlphabet("4f73vg1v") of me –Target
–>  true

set aRes to chkMixtureOfNumericAndAlphabet("4f73vg1vあああ") of me
–>  false

–数字とアルファベットの混在状態の時にtrueを返す
on chkMixtureOfNumericAndAlphabet(checkString)
  set a0Res to chkAlphabetAndNumeric(checkString) of me
  
set a1Res to chkNumeric(checkString) of me
  
set a2Res to chkAlphabet(checkString) of me
  
  
if {a0Res, a1Res, a2Res} = {true, false, false} then
    return true
  else
    return false
  end if
  
end chkMixtureOfNumericAndAlphabet

–数字のみかを調べて返す
on chkNumeric(checkString)
  set digitCharSet to current application’s NSCharacterSet’s characterSetWithCharactersInString:"0123456789"
  
set ret to my chkCompareString:checkString baseString:digitCharSet
  
return ret as boolean
end chkNumeric

— アルファベットのみか調べて返す
on chkAlphabet(checkString)
  set aStr to current application’s NSString’s stringWithString:checkString
  
set allCharSet to current application’s NSMutableCharacterSet’s alloc()’s init()
  
allCharSet’s addCharactersInRange:(current application’s NSMakeRange(ASCII number of "a", 26))
  
allCharSet’s addCharactersInRange:(current application’s NSMakeRange(ASCII number of "A", 26))
  
set aBool to my chkCompareString:aStr baseString:allCharSet
  
return aBool as boolean
end chkAlphabet

— アルファベットと数字のみか調べて返す
on chkAlphabetAndNumeric(checkString)
  set aStr to current application’s NSString’s stringWithString:checkString
  
set allCharSet to current application’s NSMutableCharacterSet’s alloc()’s init()
  
allCharSet’s addCharactersInRange:(current application’s NSMakeRange(ASCII number of "0", 10))
  
allCharSet’s addCharactersInRange:(current application’s NSMakeRange(ASCII number of "a", 26))
  
allCharSet’s addCharactersInRange:(current application’s NSMakeRange(ASCII number of "A", 26))
  
set aBool to my chkCompareString:aStr baseString:allCharSet
  
return aBool as boolean
end chkAlphabetAndNumeric

on chkCompareString:checkString baseString:baseString
  set aScanner to current application’s NSScanner’s localizedScannerWithString:checkString
  
aScanner’s setCharactersToBeSkipped:(missing value)
  
aScanner’s scanCharactersFromSet:baseString intoString:(missing value)
  
return (aScanner’s isAtEnd()) as boolean
end chkCompareString:baseString:

★Click Here to Open This Script 

Posted in Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

文字種別にカウントする v2

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:文字種別にカウントする v2
— Created 2018-1-11 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
–http://piyocast.com/as/archives/5104

property NSString : a reference to current application’s NSString
property NSNumber : a reference to current application’s NSNumber
property NSDictionary : a reference to current application’s NSDictionary
property NSCountedSet : a reference to current application’s NSCountedSet
property NSMutableArray : a reference to current application’s NSMutableArray
property NSNumberFormatter : a reference to current application’s NSNumberFormatter
property NSRegularExpressionSearch : a reference to current application’s NSRegularExpressionSearch
property NSNumberFormatterRoundUp : a reference to current application’s NSNumberFormatterRoundUp

set sourcePath to choose file of type {"public.plain-text"}
tell current application
  set aStr to (read sourcePath as «class utf8»)
end tell

set aRes to detectCharKindRating(aStr) of me
–> {kanjiNum:563289, kanjiRating:22.0, hiraganaNum:1311933, hiraganaRating:51.2, katakanaNum:210161, katakanaRating:8.2, otherNum:478690, otherRating:18.7, totalCount:2564073}–Light Novel
–> {kanjiNum:24960, kanjiRating:28.0, hiraganaNum:56080, hiraganaRating:62.9, katakanaNum:1063, katakanaRating:1.2, otherNum:7136, otherRating:8.0} –文学(坊ちゃん)

on detectCharKindRating(aStr as string)
  set theCountedSet to NSCountedSet’s alloc()’s initWithArray:(characters of aStr)
  
set theEnumerator to theCountedSet’s objectEnumerator()
  
  
set cCount to 0
  
set hCount to 0
  
set kCount to 0
  
set oCount to 0
  
set totalC to length of aStr
  
  
repeat
    set aValue to theEnumerator’s nextObject()
    
if aValue is missing value then exit repeat
    
    
set aStr to aValue as string
    
set tmpCount to (theCountedSet’s countForObject:aValue)
    
    
set s1Res to chkKanji(aStr) of me
    
set s2Res to chkKatakana(aStr) of me
    
set s3Res to chkHiragana(aStr) of me
    
    
if s1Res = true then
      set cCount to cCount + tmpCount
    else if s2Res = true then
      set kCount to kCount + tmpCount
    else if s3Res = true then
      set hCount to hCount + tmpCount
    else
      set oCount to oCount + tmpCount
    end if
  end repeat
  
  
set ckRes to roundingUp((cCount / totalC) * 100, 1) of me
  
set kkRes to roundingUp((kCount / totalC) * 100, 1) of me
  
set hgRes to roundingUp((hCount / totalC) * 100, 1) of me
  
set otRes to roundingUp((oCount / totalC) * 100, 1) of me
  
  
return {kanjiNum:cCount, kanjiRating:ckRes, hiraganaNum:hCount, hiraganaRating:hgRes, katakanaNum:kCount, katakanaRating:kkRes, otherNum:oCount, otherRating:otRes}
end detectCharKindRating

on chkKanji(aChar)
  return detectCharKind(aChar, "[一-龠]") of me
end chkKanji

on chkHiragana(aChar)
  return detectCharKind(aChar, "[ぁ-ん]") of me
end chkHiragana

on chkKatakana(aChar)
  return detectCharKind(aChar, "[ァ-ヶ]") of me
end chkKatakana

on detectCharKind(aChar, aPattern)
  set aChar to NSString’s stringWithString:aChar
  
set searchStr to NSString’s stringWithString:aPattern
  
set matchRes to aChar’s rangeOfString:searchStr options:(NSRegularExpressionSearch)
  
if matchRes’s location() = (current application’s NSNotFound) or (matchRes’s location() as number) > 9.99999999E+8 then
    return false
  else
    return true
  end if
end detectCharKind

on roundingUp(aNum, aDigit as integer)
  set a to aNum as real
  
set aFormatter to NSNumberFormatter’s alloc()’s init()
  
aFormatter’s setMaximumFractionDigits:aDigit
  
aFormatter’s setRoundingMode:(NSNumberFormatterRoundUp)
  
set aStr to aFormatter’s stringFromNumber:(NSNumber’s numberWithFloat:a)
  
return (aStr as text) as real
end roundingUp

★Click Here to Open This Script 

Posted in Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

文字種類変換(ASOC)

Posted on 2月 6, 2018 by Takaaki Naganoya

テキストの各種文字の変換を行うAppleScriptです。

半角カタカナから全角への変換など、いまやテキストエディタの機能など用いる必要もなく、Cocoaの機能を呼び出すと手軽に行うことができます。

AppleScript名:文字種類変換(ASOC)
— Created 2017-09-06 by Shane Stanley
— Modified 2017-09-06 by Takaaki Naganoya
use AppleScript version "2.5" — (10.12) or later
use framework "Foundation"
use scripting additions
–http://piyocast.com/as/archives/4811

property NSString : a reference to current application’s NSString
property NSStringTransformFullwidthToHalfwidth : a reference to current application’s NSStringTransformFullwidthToHalfwidth
property NSStringTransformHiraganaToKatakana : a reference to current application’s NSStringTransformHiraganaToKatakana
property NSStringTransformLatinToHiragana : a reference to current application’s NSStringTransformLatinToHiragana
property NSStringTransformLatinToKatakana : a reference to current application’s NSStringTransformLatinToKatakana
property NSStringTransformToUnicodeName : a reference to current application’s NSStringTransformToUnicodeName
property NSStringTransformToXMLHex : a reference to current application’s NSStringTransformToXMLHex

set a01 to hanToZen("トウキョウト") of me
–>  "トウキョウト"–Zenkaku (Full Width)

set a02 to zenToHan(a01) of me
–>  "トウキョウト" –Hankaku (Half Width)

set a03 to katakanaToHiraganaTo(a01) of me
–>  "とうきょうと"

set a04 to hiraganaToKatakana(a03) of me
–>  "トウキョウト"

set a05 to hiraganaToalphabet(a03) of me
–>  "toukyouto"

set a06 to alphabetToHiragana(a05) of me
–>  "とうきょうと"

set a07 to katakanaToAlphabet(a04) of me
–>  "toukyouto"

set a08 to alphabetToKatakana(a07) of me
–>  "トウキョウト"

set a09 to characterToUnicodeName("あ") of me
–>  "\\N{HIRAGANA LETTER A}"

set a10 to unicodeNameToCharacter(a09) of me
–>  "あ"

set a11 to stringToXMLHex("あ") of me
–>  "&#x3042;"

set a12 to xmlHexTostring(a11) of me
–>  "あ"

–半角→全角変換
on hanToZen(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformFullwidthToHalfwidth) |reverse|:true) as string
end hanToZen

–全角→半角変換
on zenToHan(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformFullwidthToHalfwidth) |reverse|:false) as string
end zenToHan

–ひらがな→カタカナ変換
on hiraganaToKatakana(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformHiraganaToKatakana) |reverse|:false) as string
end hiraganaToKatakana

–カタカナ→ひらがな変換
on katakanaToHiraganaTo(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformHiraganaToKatakana) |reverse|:true) as string
end katakanaToHiraganaTo

–ローマ字→ひらがな変換
on alphabetToHiragana(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformLatinToHiragana) |reverse|:false) as string
end alphabetToHiragana

–ひらがな→ローマ字変換
on hiraganaToalphabet(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformLatinToHiragana) |reverse|:true) as string
end hiraganaToalphabet

–ローマ字→カタカナ変換
on alphabetToKatakana(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformLatinToKatakana) |reverse|:false) as string
end alphabetToKatakana

–カタカナ→ローマ字変換
on katakanaToAlphabet(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformLatinToKatakana) |reverse|:true) as string
end katakanaToAlphabet

–文字→Unicode Name変換
on characterToUnicodeName(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformToUnicodeName) |reverse|:false) as string
end characterToUnicodeName

–Unicode Name→文字変換
on unicodeNameToCharacter(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformToUnicodeName) |reverse|:true) as string
end unicodeNameToCharacter

–文字→XML Hex変換
on stringToXMLHex(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformToXMLHex) |reverse|:false) as string
end stringToXMLHex

–XML Hex→文字変換
on xmlHexTostring(aStr)
  set aString to NSString’s stringWithString:aStr
  
return (aString’s stringByApplyingTransform:(NSStringTransformToXMLHex) |reverse|:true) as string
end xmlHexTostring


★Click Here to Open This Script 

Posted in Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

原稿用紙枚数シミュレーション(簡易版)v1

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:原稿用紙枚数シミュレーション(簡易版)v1
— Created 2018-1-13 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
–http://piyocast.com/as/archives/5120

set aText to retTestText() of me

set sRes to genkoSimulation(20, 20, aText) of me
display notification "原稿用紙換算で約" & (sRes as string) & "枚です"

–原稿用紙枚数シミュレーション(簡易版)
on genkoSimulation(lineMax as integer, genkoLineMax as integer, aText as string)
  script spdT
    property aList : {}
  end script
  
  
if aText = "" then return 0
  
  
set (aList of spdT) to characters of aText
  
set charPointer to 1
  
set lineCounter to 1
  
set aLen to length of (aList of spdT)
  
  
set i to 1
  
  
repeat while i < aLen
    set j to contents of item i of (aList of spdT)
    
    
    
if j is in {string id 10, string id 13, string id 10 & string id 13} then
      set charPointer to 1
      
set lineCounter to lineCounter + 1
    else
      
      
set charPointer to charPointer + 1
      
      
if charPointer ≥ lineMax then
        set charPointer to 1
        
set lineCounter to lineCounter + 1
      end if
    end if
    
    
set i to i + 1
  end repeat
  
  
set totalPage to lineCounter div genkoLineMax
  
set amariPage to lineCounter mod genkoLineMax
  
if amariPage = 0 then
    —
  else
    set totalPage to totalPage + 1
  end if
  
  
return totalPage
end genkoSimulation

on retTestText()
  return "12345
あいうえお
かきくけこ
さしすせそ
たちつてと
なにぬねの
はひふへほ
まみむめも
やいゆえよ
わいうえを
あいうえお
かきくけこ
さしすせそ
たちつてと
なにぬねの
はひふへほ
まみむめも
やいゆえよ
わいうえを
1234567890123456789ぉー"

end retTestText

★Click Here to Open This Script 

Posted in Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

love

Posted on 2月 6, 2018 by Takaaki Naganoya

Basicで作られた花文字プログラムを、AppleScriptに移植したものです。元は、ChipmunkBasic用のサンプルプログラムで、1996年作成のクレジットが銘打たれていますが、オリジナルはもっと昔に作られたものでしょう。

図形パターンは西新宿に置かれているロバート・インディアナ氏作のオブジェ「LOVE」(1965年発表)のデータそのものです。

下地に敷く文字は変更できますが、模様の文字列(LOVE)は固定データで持たせているので、そのままでは変更できません。

→ その後、英単語の花文字プログラムを作成してみました。

AppleScript名:love
— Created 2015-02-15 by Takaaki Naganoya
— 2015 Piyomaru Software

(*
20 rem PRINT "THANKS TO ROBERT INDIANA AND DAVID AHL"
21 rem print "contributed by ATStarr@Amherst.Edu 1996"
http://www.nicholson.com/rhn/basic/classic_programs/love.bas
*)

set charMode to "E" –J or E
set aTargChar to "makiko"
set outText to ""
set aSpc to returnSpc(charMode) of me

set aList to retLoveList()

set aPos to 0
set charFlag to true –false:space char

repeat with i in aList
  set j to contents of i
  
if charFlag = true then
    set aText to retCirculateStrs(aTargChar, j) of me
  else
    set aText to retCirculateStrs(aSpc, j) of me
  end if
  
  
set outText to outText & aText
  
  
set charFlag to not charFlag
  
  
set aPos to aPos + j
  
if aPos ≥ 60 then
    set aPos to 0
    
set outText to outText & return
    
set charFlag to true
  end if
end repeat

return outText

on retLoveList()
  return {60, 1, 12, 26, 9, 12, 3, 8, 24, 17, 8, 4, 6, 23, 21, 6, 4, 6, 22, 12, 5, 6, 5, 4, 6, 21, 11, 8, 6, 4, 4, 6, 21, 10, 10, 5, 4, 4, 6, 21, 9, 11, 5, 4, 4, 6, 21, 8, 11, 6, 4, 4, 6, 21, 7, 11, 7, 4, 4, 6, 21, 6, 11, 8, 4, 4, 6, 19, 1, 1, 5, 11, 9, 4, 4, 6, 19, 1, 1, 5, 10, 10, 4, 4, 6, 18, 2, 1, 6, 8, 11, 4, 4, 6, 17, 3, 1, 7, 5, 13, 4, 4, 6, 15, 5, 2, 23, 5, 1, 29, 5, 17, 8, 1, 29, 9, 9, 12, 1, 13, 5, 40, 1, 1, 13, 5, 40, 1, 4, 6, 13, 3, 10, 6, 12, 5, 1, 5, 6, 11, 3, 11, 6, 14, 3, 1, 5, 6, 11, 3, 11, 6, 15, 2, 1, 6, 6, 9, 3, 12, 6, 16, 1, 1, 6, 6, 9, 3, 12, 6, 7, 1, 10, 7, 6, 7, 3, 13, 6, 6, 2, 10, 7, 6, 7, 3, 13, 14, 10, 8, 6, 5, 3, 14, 6, 6, 2, 10, 8, 6, 5, 3, 14, 6, 7, 1, 10, 9, 6, 3, 3, 15, 6, 16, 1, 1, 9, 6, 3, 3, 15, 6, 15, 2, 1, 10, 6, 1, 3, 16, 6, 14, 3, 1, 10, 10, 16, 6, 12, 5, 1, 11, 8, 13, 27, 1, 11, 8, 13, 27, 1, 60}
end retLoveList

–Return Space (English Char/Japanese Char)
on returnSpc(aMode)
  if aMode = "E" then return " " –Single character Space
  
if aMode = "J" then return " " –Japanese Double Width Space
end returnSpc

on retCirculateStrs(aText, repCharTimes)
  set aLen to length of aText
  
set aTimes to repCharTimes div aLen
  
set aMod to repCharTimes mod aLen
  
set outStr to ""
  
  
repeat aTimes times
    set outStr to outStr & aText
  end repeat
  
  
if aMod is not equal to 0 then
    set aModStr to text 1 thru aMod of aText
    
set outStr to outStr & aModStr
  end if
  
  
return outStr
end retCirculateStrs

★Click Here to Open This Script 

Posted in Text | Tagged 10.11savvy 10.12savvy 10.13savvy | 2 Comments

指定文字列前後から空白や改行を削除

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:指定文字列前後から空白や改行を削除
— Created 2018-01-29 by Takaaki Naganoya
— 2018 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aStr to "

aaaaaa

"

set aString to current application’s NSString’s stringWithString:aStr
set bStr to (aString’s stringByTrimmingCharactersInSet:(current application’s NSCharacterSet’s whitespaceAndNewlineCharacterSet()))

return bStr as string

–>  "aaaaaa"

★Click Here to Open This Script 

Posted in Text | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Dockアイコンにプログレスバーを追加

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:Dockアイコンにプログレスバーを追加
use AppleScript
use framework "Foundation"
use scripting additions

on run
  set max to 100
  
repeat with num from 1 to max
    my progDockTile(max, num)
    
delay 0.1
  end repeat
  
  
#アイコンを元に戻す
  
current application’s NSApp’s setApplicationIconImage:(current application’s NSImage’s imageNamed:"NSApplicationIcon")
end run

#Dockアイコンにプログレスバーを追加
on progDockTile(max, current)
  set appIcon to current application’s NSImage’s imageNamed:"NSApplicationIcon"
  
set iconSize to appIcon’s |size|()
  
  
tell (current application’s NSImage’s alloc()’s initWithSize:iconSize)
    
    
lockFocus()
    
    
appIcon’s dissolveToPoint:(current application’s NSZeroPoint) fraction:1.0
    
set n to (iconSize’s width) / 16
    
    
#プログレスバーの長方形
    
set myRect to current application’s NSMakeRect(n / 2, n, n * 15, n * 1.6) –>{origin:{x:4.0, y:8.0}, |size|:{width:120.0, height:12.800000190735}}
    
    
tell (current application’s NSBezierPath’s ¬
      bezierPathWithRoundedRect:myRect ¬
        xRadius:(myRect’s |size|’s height) / 2 ¬
        
yRadius:(myRect’s |size|’s height) / 2)
      
      
current application’s (NSColor’s colorWithWhite:1.0 alpha:0.4)’s |set|() –>背景色
      
fill()
      
      
current application’s NSColor’s whiteColor()’s |set|() –>枠色
      
stroke()
    end tell
    
    
if current is greater than 0 then
      
      
if current is greater than max then set current to max
      
      
set myRect’s |size|’s width to (myRect’s |size|’s width) / max * current
      
      
tell (current application’s NSBezierPath’s ¬
        bezierPathWithRoundedRect:myRect ¬
          xRadius:(myRect’s |size|’s height) / 2 ¬
          
yRadius:(myRect’s |size|’s height) / 2)
        
        
set strartColor to current application’s NSColor’s colorWithRed:0.15 green:0.55 blue:1 alpha:0.8
        
set endColor to strartColor’s shadowWithLevel:0.7
        
set grad to current application’s NSGradient’s alloc()’s initWithStartingColor:strartColor endingColor:endColor
        
grad’s drawInBezierPath:it angle:270.0
      end tell
    end if
    
    
unlockFocus()
    
    
current application’s NSApp’s setApplicationIconImage:it
  end tell
  
  
return (current + 1)
end progDockTile

★Click Here to Open This Script 

Posted in System | Tagged 10.11savvy 10.12savvy 10.13savvy Dock | Leave a comment

Dockとメニューバーを隠す→戻す

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:Dockとメニューバーを隠す→戻す
— Created 2017-03-15 by Takaaki Naganoya
— 2017 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
–http://piyocast.com/as/archives/4529

–Main MenuとDockを隠す
current application’s NSApplication’s sharedApplication()’s setPresentationOptions:10 –NSApplicationPresentationHideMenuBar | NSApplicationPresentationHideDock

delay 10

–MenuとDockを通常に戻す
current application’s NSApplication’s sharedApplication()’s setPresentationOptions:(current application’s NSApplicationPresentationDefault)

★Click Here to Open This Script 

Posted in System | Tagged 10.11savvy 10.12savvy 10.13savvy Dock | Leave a comment

2月1日が日曜日でうるう年ではないかチェック(ASOC)

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:2月1日が日曜日でうるう年ではないかチェック(ASOC)
— Created 2015-02-02 by Shane Stanley
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
–use framework "ASObjCExtras"

set resYList to {} –hit year

set theNSCalendar to current application’s NSCalendar’s currentCalendar() — do *not* use initWithCalendarIdentifier:

repeat with y from 2000 to 2100
  set aMlen to getMlenAndVerifyFirstDaysNum(y, 2, theNSCalendar, 28, 1) of me
  
if aMlen = true then
    set the end of resYList to y
  end if
  
–set the end of resYList to aMlen
end repeat

return resYList
–>  {​​​​​2009, ​​​​​2015, ​​​​​2026, ​​​​​2037, ​​​​​2043, ​​​​​2054, ​​​​​2065, ​​​​​2071, ​​​​​2082, ​​​​​2093, ​​​​​2099​​​}

on getMlenAndVerifyFirstDaysNum(aYear, aMonth, theNSCalendar, dMax, fdayNum)
  
  
–現在のLocaleのCalendarで指定年月の日数をかぞえる
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:1 hour:0 minute:0 |second|:0 nanosecond:0
  
set theResult to theNSCalendar’s rangeOfUnit:(current application’s NSDayCalendarUnit) inUnit:(current application’s NSMonthCalendarUnit) forDate:theDate
  
–>  {location:1, length:31}
  
set mLen to |length| of theResult
  
  
–指定年月の1日を取得
  
set theDay to theNSCalendar’s components:((current application’s NSWeekdayCalendarUnit) + (current application’s NSMonthCalendarUnit as integer)) fromDate:theDate
  
  
–指定年月の1日の曜日が指定曜日で、うるう月でなく、指定年月の日数が指定日数(dMax)であるか判定
  
if (theDay’s |weekday|() = fdayNum) and (theDay’s isLeapMonth() is false) and (mLen = dMax) then
    return true
  else
    return false
  end if
  
end getMlenAndVerifyFirstDaysNum

★Click Here to Open This Script 

Posted in 未分類 | Tagged 10.11savvy 10.12savvy 10.13savvy Calendar | Leave a comment

国民の祝日を求める v4

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:国民の祝日を求める v4
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"

(*

本バージョンのテーマ:

日付ベースだけでカレンダー計算を行うのではなく、祝日の名称や振替休日といった属性情報を考慮しつつ計算を行う
元日の振替休日に対応

*)

set aList to retHolidayRec(2018) of me

–> {{date "2018年1月1日月曜日 0:00:00", "元旦"}, {date "2018年1月8日月曜日 0:00:00", "成人の日"}, {date "2018年2月11日日曜日 0:00:00", "建国記念日"}, {date "2018年2月12日月曜日 0:00:00", "振替休日"}, {date "2018年3月21日水曜日 0:00:00", "春分の日"}, {date "2018年4月29日日曜日 0:00:00", "昭和の日"}, {date "2018年4月30日月曜日 0:00:00", "振替休日"}, {date "2018年5月3日木曜日 0:00:00", "憲法記念日"}, {date "2018年5月4日金曜日 0:00:00", "みどりの日"}, {date "2018年5月5日土曜日 0:00:00", "こどもの日"}, {date "2018年7月16日月曜日 0:00:00", "海の日"}, {date "2018年9月17日月曜日 0:00:00", "敬老の日"}, {date "2018年9月23日日曜日 0:00:00", "秋分の日"}, {date "2018年9月24日月曜日 0:00:00", "振替休日"}, {date "2018年10月8日月曜日 0:00:00", "体育の日"}, {date "2018年11月3日土曜日 0:00:00", "文化の日"}, {date "2018年11月23日金曜日 0:00:00", "勤労感謝の日"}, {date "2018年12月23日日曜日 0:00:00", "天皇誕生日"}, {date "2018年12月24日月曜日 0:00:00", "振替休日"}}

–国民の祝日を求める(属性つき)
on retHolidayRec(aYear)
  set holidayList to {{"1/1", "元旦"}, {"2/11", "建国記念日"}, {"4/29", "昭和の日"}, {"5/3", "憲法記念日"}, {"5/4", "みどりの日"}, {"5/5", "こどもの日"}, {"11/3", "文化の日"}, {"11/23", "勤労感謝の日"}, {"12/23", "天皇誕生日"}}
  
  
set the end of holidayList to {get_specifiedDay(aYear, 1, 2, 2), "成人の日"} –成人の日–1月の第2月曜日
  
set the end of holidayList to {get_specifiedDay(aYear, 7, 2, 3), "海の日"} –海の日–7月の第3月曜日
  
set the end of holidayList to {get_specifiedDay(aYear, 9, 2, 3), "敬老の日"} –敬老の日–9月の第3月曜日
  
set the end of holidayList to {get_specifiedDay(aYear, 10, 2, 2), "体育の日"} –体育の日–10月の第2月曜日
  
set the end of holidayList to {"3/" & get_ShunbunNoHi(aYear), "春分の日"} –春分の日
  
set the end of holidayList to {"9/" & get_ShuubunNoHi(aYear), "秋分の日"} –秋分の日
  
  
set holiDate to {}
  
repeat with i in holidayList
    set holiD to date (((aYear as text) & "/" & item 1 of i) as text)
    
set holiNum to weekday of holiD as number
    
    
–元日以外を対象とする(元旦に振替休日なし)–> いや、ある(汗)
    
–if ((item 1 of i) as text) is not "1/1" then
    
–振替休日付加処理
    
if holiNum = 1 then –祝祭日が日曜日だったら
      –日付を動かすのではなく、振替休日を追加する
      
set holiD_furikae to holiD + (1 * days)
      
set the end of holiDate to {holiD_furikae, "振替休日"}
    end if
    
–end if
    
set the end of holiDate to {holiD, item 2 of i}
    
  end repeat
  
  
  
–重複した休日が発生した場合の再振替処理  
  
–基本ルール:  振替休日を後に送る
  
–        「振替休日」が重複リストに入っていないかどうかをチェックし、振替休日の再配置を行う
  
set itemNum to 1
  
set holiDateDup to detectDuplicatesFromNestedList(holiDate, itemNum) of me
  
  
set huriList to {}
  
repeat with i in holiDateDup
    set iCount to length of i
    
repeat with ii in i
      set {aDate, aDateName} to ii
      
if aDateName = "振替休日" then
        set the end of huriList to contents of ii
      end if
    end repeat
  end repeat
  
  
set holiDate to shellSortListAscending(holiDate, 1) of me
  
set holiDateList to spritOrderedItemFromNestedList(holiDate, 1) of me
  
  
repeat with i in huriList
    set {aDate, aName} to i
    
set j to contents of i
    
set offsetDate to 1
    
repeat
      set bDate to aDate + (offsetDate * days)
      
if bDate is not in holiDateList then
        exit repeat
      end if
      
set offsetDate to offsetDate + 1
    end repeat
    
    
set iCount to 1
    
repeat with ii in holiDate
      set jj to contents of ii
      
if jj = j then
        –「複数要素一括削除サブルーチン」などという高機能すぎるサブルーチンを使用。ちょっともったいない
        
set holiDate to itemsDelete(holiDate, {iCount}) of me
      end if
      
set iCount to iCount + 1
    end repeat
    
    
set the end of holiDate to {bDate, "振替休日"}
    
  end repeat
  
  
  
–秋分の日と敬老の日の「間の日」の休日判定処理
  
–参考文献:
  
–http://ja.wikipedia.org/wiki/秋分の日
  
set septDL to {}
  
set the end of septDL to "9/" & get_ShuubunNoHi(aYear) of me –秋分の日
  
set the end of septDL to get_specifiedDay(aYear, 9, 2, 3) –敬老の日 –9月の第3月曜日
  
set septDL to shellSort(septDL) of me
  
if septDL = {"9/21", "9/23"} then
    set kokuminShukujitu to (aYear as string) & "/9/22"
    
set kokuminShukujitu to date kokuminShukujitu
    
set the end of holiDate to {kokuminShukujitu, "国民の祝日"}
  end if
  
  
–最後に、並べ替えを行って仕上げ
  
set holiDate to shellSortListAscending(holiDate, 1) of me
  
  
return holiDate
  
end retHolidayRec

–春分の日を求める
–2000年から2099年の間まで計算可能
on get_ShunbunNoHi(aYear)
  set a to 20.69115
  
set b to (aYear – 2000) * 0.2421904
  
set c to round ((aYear – 2000) / 4) rounding toward zero
  
set d to round (a + b – c) rounding toward zero
  
return d
end get_ShunbunNoHi

–秋分の日を求める
–2000年から2099年の間まで計算可能
on get_ShuubunNoHi(aYear)
  set a to 23.09
  
set b to (aYear – 2000) * 0.2421904
  
set c to round ((aYear – 2000) / 4) rounding toward zero
  
set d to round (a + b – c) rounding toward zero
  
return d
end get_ShuubunNoHi

–指定月の第x指定曜日に該当する日付を求める(mm/dd形式)
– 曜日の指定を数値(weekday of (current date) as number)で行えるようにした。
– 曜日を「日曜日」などの日本語ローカライズド文字列で指定するのをやめた
–パラメータ: 年, 月, 曜日番号, 順番
on get_specifiedDay(aYear as integer, aMonth as integer, Youbi as integer, orderNum as integer)
  set sDat to date ((aYear & "/" & aMonth & "/1") as text)
  
set eDat to getMlenInternational(aYear, aMonth) of me
  
  
set countNum to 0
  
  
repeat with i from 1 to eDat
    set aCal to date ((aYear & "/" & aMonth & "/" & (i as text)) as text)
    
set aWeekDayNum to weekday of aCal as number
    
if Youbi = aWeekDayNum then
      set countNum to countNum + 1
      
if countNum is orderNum then
        set aCalText to (aMonth & "/" & i as text)
        
return aCalText
      end if
    end if
  end repeat
end get_specifiedDay

–指定日の月のみ返す
on getMonth(aDat as date)
  set bDate to month of aDat
  
return bDate as number
end getMonth

–指定日の日付のみ返す
on getDate(aDat as date)
  set bDate to day of aDat
  
return bDate as number
end getDate

–指定日の年のみ返す
on getYear(aDat as date)
  set bDate to year of aDat
  
return bDate as number
end getYear

–現在のカレンダーで指定年月の日数を返す(getMlenから置き換えた)
on getMlenInternational(aYear, aMonth)
  set theNSCalendar to current application’s NSCalendar’s currentCalendar() — do *not* use initWithCalendarIdentifier:
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:1 hour:0 minute:0 |second|:0 nanosecond:0
  
set theResult to theNSCalendar’s rangeOfUnit:(current application’s NSDayCalendarUnit) inUnit:(current application’s NSMonthCalendarUnit) forDate:theDate
  
return |length| of theResult
end getMlenInternational

–リスト中から重複項目をリストアップする
on detectDuplicates(aList)
  set aCount to length of aList
  
  
set duplicationList to {}
  
repeat aCount times
    set anItem to contents of (first item of aList)
    
set aList to rest of aList
    
if anItem is in aList then
      set the end of duplicationList to anItem
    end if
  end repeat
  
  
return duplicationList
end detectDuplicates

–リストから重複部分を除外
on removeDuplicates(aList)
  set newList to {}
  
repeat with i from 1 to (length of aList)
    set anItem to item 1 of aList
    
set aList to rest of aList
    
if {anItem} is not in aList then set end of newList to anItem
  end repeat
  
return newList
end removeDuplicates

–シェルソート
on shellSort(aSortList)
  script oBj
    property list : aSortList
  end script
  
set len to count oBj’s list’s items
  
set gap to 1
  
repeat while (gap ≤ len)
    set gap to ((gap * 3) + 1)
  end repeat
  
repeat while (gap > 0)
    set gap to (gap div 3)
    
if (gap < len) then
      repeat with i from gap to (len – 1)
        set temp to oBj’s list’s item (i + 1)
        
set j to i
        
repeat while ((j ≥ gap) and (oBj’s list’s item (j – gap + 1) > temp))
          set oBj’s list’s item (j + 1) to oBj’s list’s item (j – gap + 1)
          
set j to j – gap
        end repeat
        
set oBj’s list’s item (j + 1) to temp
      end repeat
    end if
  end repeat
  
return oBj’s list
end shellSort

–シェルソートで入れ子のリストを昇順ソート
on shellSortListAscending(a, keyItem)
  set n to length of a
  
set cols to {1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1}
  
repeat with h in cols
    if (h ≤ (n – 1)) then
      repeat with i from h to (n – 1)
        set v to item (i + 1) of a
        
set j to i
        
repeat while (j ≥ h) and ((contents of item keyItem of item (j – h + 1) of a) > (item keyItem of v))
          set (item (j + 1) of a) to (item (j – h + 1) of a)
          
set j to j – h
        end repeat
        
set item (j + 1) of a to v
      end repeat
    end if
  end repeat
  
return a
end shellSortListAscending

–シェルソートで入れ子のリストを降順ソート
on shellSortListDecending(a, keyItem)
  set n to length of a
  
set cols to {1391376, 463792, 198768, 86961, 33936, 13776, 4592, 1968, 861, 336, 112, 48, 21, 7, 3, 1}
  
repeat with h in cols
    if (h ≤ (n – 1)) then
      repeat with i from h to (n – 1)
        set v to item (i + 1) of a
        
set j to i
        
repeat while (j ≥ h) and ((contents of item keyItem of item (j – h + 1) of a) < (item keyItem of v))
          set (item (j + 1) of a) to (item (j – h + 1) of a)
          
set j to j – h
        end repeat
        
set item (j + 1) of a to v
      end repeat
    end if
  end repeat
  
return a
end shellSortListDecending

–入れ子のリスト中から重複項目をアイテム番号つきでリストアップする
on detectDuplicatesFromNestedList(aList, itemNum)
  set aCount to length of aList
  
copy aList to orig_aList
  
  
set duplicationList to {}
  
repeat aCount times
    set anItem to contents of (first item of aList)
    
set aList to rest of aList
    
    
–指定アイテムだけのリストを毎回再生成して存在確認を行う
    
set aaList to spritOrderedItemFromNestedList(aList, itemNum) of me
    
if (contents of (item itemNum of anItem)) is in aaList then
      set the end of duplicationList to anItem
    end if
    
  end repeat
  
  
–検出した重複データを元に、該当するデータをリストアップ
  
set detectList to {}
  
repeat with i in duplicationList
    set j to contents of (item itemNum of i)
    
set detectItem to {}
    
repeat with ii in orig_aList
      set jj to contents of (item itemNum of ii)
      
      
if jj = j then
        set the end of detectItem to (contents of ii)
      end if
    end repeat
    
set the end of detectList to detectItem
  end repeat
  
  
return detectList
end detectDuplicatesFromNestedList

–入れ子のリストの全要素から指定アイテム目の要素だけを取り出してリストで返す
on spritOrderedItemFromNestedList(aList, itemNum)
  set aaList to {}
  
repeat with i in aList
    set the end of aaList to contents of (item itemNum of i)
  end repeat
  
return aaList
end spritOrderedItemFromNestedList

–リスト中の指定要素を削除して返す
on itemsDelete(aList, delNumList)
  set delLen to length of delNumList
  
  
repeat with i from 1 to delLen
    
    
set newList to {}
    
set aLen to length of aList
    
    
set ii to item i of delNumList
    
    
if ii = 1 then
      set maeList to items 2 thru aLen of aList
      
set newList to maeList
      
    else if ii = aLen then
      set maeList to items 1 thru (aLen – 1) of aList
      
set newList to maeList
      
    else
      set maeList to items 1 thru (ii – 1) of aList
      
set atoList to items (ii + 1) thru -1 of aList
      
set newList to maeList & atoList
    end if
    
    
–アイテム指定の補正
    
set delNumList to adjustItemNo(ii, delNumList) of me
    
log delNumList
    
    
set aList to newList
  end repeat
  
  
return newList
end itemsDelete

–itemsDeleteのサブルーチン
–リストに対して複数アイテムの削除を行う場合に、1つ削除した後にはアイテム指定が
–狂ってしまうため、毎回削除するたびにアイテム指定の補正を行う
–paramNumとelemListの間でのパラメータの衝突は関知しない

–項目要素補正をリストに対して行う
on adjustItemNo(paramNum, elemList)
  –項目ゼロを指定してきた場合には、そのままelemListを戻す
  
if paramNum = 0 then return elemList
  
–プラス方向のレンジ外判定は行っていない。elemListのlengthよりも大きな値は関知しない
  
set retList to {}
  
repeat with i in elemList
    set j to contents of i
    
if j > paramNum then
      set ansNum to j – 1
    else
      set ansNum to j
    end if
    
set the end of retList to ansNum
  end repeat
  
  
return retList
end adjustItemNo

–現在のカレンダーで指定年月のdate objectを返す(年、月、日、時、分、秒)
on getDateInternationalYMDhms(aYear, aMonth, aDay, anHour, aMinute, aSecond)
  set theNSCalendar to current application’s NSCalendar’s currentCalendar()
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:aDay hour:anHour minute:aMinute |second|:aSecond nanosecond:0
  
return theDate as date
end getDateInternationalYMDhms

–現在のカレンダーで指定年月のdate objectを返す(年、月、日)
on getDateInternational(aYear, aMonth, aDay)
  set theNSCalendar to current application’s NSCalendar’s currentCalendar()
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:aDay hour:0 minute:0 |second|:0 nanosecond:0
  
return theDate as date
end getDateInternational

★Click Here to Open This Script 

Posted in Calendar | Tagged 10.11savvy 10.12savvy 10.13savvy Calendar | Leave a comment

自然言語による相対日付指定v15

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:自然言語による相対日付指定v15
use AppleScript version "2.5"
use scripting additions
use framework "Foundation"
–v15 ASOCの部品に入れ替え、macOS 10.11以降用にハンドラの型強制オプションをつけた
–v14 10.8の上で動作するように書き換えた

–The Calendar Scripting Module

global d3List –3か月カレンダーの格納変数
global d4List –3か月カレンダーBの格納変数(当月の情報しか日付は入っていないカレンダー)
global weekCounter — 今日が3か月カレンダーの何週目にあたるか

set aDate to calcDate("今日", "") of me
log {"今日:" & aDate as text}

set aDate to calcDate("先々週", "水曜日") of me
log {"先々週の水曜日:" & aDate as text}

set aDate to calcDate("来週", "金曜") of me
log {"来週の金曜日:" & aDate as text}

on calcDate(param1 as string, param2 as string)
  
  
–相対日付指定パラメータテーブル
  
–data sample: {{"今日", "きょう"}, 0, "date"}
  
–data format:{{"keyword_1", "keyword_2"…."keyword_n"}, vector, "class_of_this_keyword"}
  
  
–Vector量をその場で(ユーザー環境に応じて)算出もしくは取得する必要がある場合には「999」を設定しておく
  
  
set dDat to {{{"来年"}, 1, "year"}, {{"今年"}, 0, "year"}, {{"去年"}, -1, "year"}, {{"再来年"}, 2, "year"}, {{"今週"}, 0, "week"}, {{"先週"}, -1, "week"}, {{"先々週"}, -2, "week"}, {{"来週"}, 1, "week"}, {{"再来週"}, 2, "week"}, {{"今日", "きょう"}, 0, "date"}, {{"明日", "あした"}, 1, "date"}, {{"明後日", "あさって"}, 2, "date"}, {{"明々後日", "しあさって"}, 3, "date"}, {{"昨日", "きのう"}, -1, "date"}, {{"一昨日", "おととい"}, -2, "date"}, {{"一昨々日", "さきおととい"}, -3, "date"}, {{"次", "今度", "こんど", "つぎ"}, 1, "variable"}, {{"前"}, -1, "variable"}}
  
  
–曜日指定パラメータ
  
set wDat to {"日曜日", "月曜日", "火曜日", "水曜日", "木曜日", "金曜日", "土曜日", "日曜", "月曜", "火曜", "水曜", "木曜", "金曜", "土曜", "にちようび", "げつようび", "かようび", "すいようび", "もくようび", "きんようび", "どようび", "にちよう", "げつよう", "かよう", "すいよう", "もくよう", "きんよう", "どよう"}
  
  
–3か月カレンダーを作成
  
makeCalendar() of me
  
  
–今日の日付を保持
  
set todayDate to current date
  
  
–指定週の計算用ワーク変数
  
set targetWeek to 0
  
  
–指定月の計算用ワーク変数
  
set targetMonth to (month of todayDate) as number
  
set targetYear to year of todayDate
  
set targetDate to day of todayDate
  
  
set aItem to ""
  
repeat with i in dDat
    if param1 is in item 1 of i then
      copy i to aItem
      
exit repeat
    end if
  end repeat
  
  
if (item 3 of aItem) is "date" then
    log "Hit date class parameter"
    
–dateレベルのパラメータの場合
    
set retDate to todayDate + (item 2 of aItem) * days
    
set time of retDate to 0
    
return retDate
    
–「時刻を問わない」ことを示す表現として、00時を指定してdate型を返す
    
  else if item 3 of aItem is "week" then
    log "hit week class parameter"
    
    
–weekレベルのパラメータの場合
    
set targetWeek to weekCounter + (item 2 of aItem)
    
if param2 is in wDat then
      
      
–パラメータが「何曜日か?」を得る
      
set tmpD to 1
      
repeat with j in wDat
        if param2 is contents of j then exit repeat
        
set tmpD to tmpD + 1
      end repeat
      
      
if tmpD > 7 then
        set tmpD to tmpD mod 7
      end if
      
      
–今月か?
      
if item tmpD of item targetWeek of d4List is 0 then
        –今月ではない場合
        
set tmp2 to item tmpD of item targetWeek of d3List
        
if ((item 2 of aItem) < 0) then
          –今月ではなく、パラメータがマイナスの週計算を行う場合
          
–先月に入ったので月を減らす
          
set targetMonth to targetMonth – 1
          
set tmp4 to (targetYear & "/" & targetMonth & "/" & tmp2) as string
          
set ret2Date to date (tmp4 & " 0:00:00")
          
return ret2Date
        else
          –来月として処理
          
set targetMonth to targetMonth + 1
          
set tmp4 to (targetYear & "/" & targetMonth & "/" & tmp2) as string
          
set ret2Date to date (tmp4 & " 0:00:00")
          
return ret2Date
        end if
      else
        –今月の場合の処理
        
set tmp2 to item tmpD of item targetWeek of d3List
        
set tmp3 to day of todayDate
        
        
set tmp4 to (targetYear & "/" & targetMonth & "/" & tmp2) as string
        
set ret2Date to date (tmp4 & " 0:00:00")
        
return ret2Date
        
      end if
      
    else
      –ここはエラーを返すべし("来週","")といったパターンになるので
      
—-あるいは、「○○日」といったダイレクトパラメータの処理を行う
      
      
–日付ダイレクトパラメータの処理
      
      
error "日付を特定するためのパラメータがありません"
      
(*
      ただし、このように決め打ちでエラーメッセージを返すような実装は暫定仕様。
      何が欠けているかをGUIフィードバックするのが最終的な実装
      *)

    end if
  else if item 3 of aItem is "month" then
    –monthレベルのパラメータの場合
    
log "Hit month class parameter"
    
  else if item 3 of aItem is "year" then
    –yearレベルのパラメータの場合
    
log "Hit year class parameter"
    
  end if
  
  
return "no hit"
end calcDate

–相対日付計算用の3か月カレンダーを作成する
on makeCalendar()
  
  
set aToday to current date
  
  
–とりあえず、当月の情報を収集する
  
set y1 to getYear(aToday) of me
  
set m1 to getMonth(aToday) of me
  
set d1 to getDate(aToday) of me
  
set dy1 to getDay(aToday) of me
  
set mlen1 to getMlen(y1, m1) of me
  
  
set mXDay to getDay(aToday) of me –今日の曜日
  
  
–前月の情報を組み立てる
  
if m1 is not equal to 1 then
    –2〜12月の場合
    
set y0 to y1
    
set m0 to m1 – 1
  else
    –1月の場合
    
set y0 to y1 – 1
    
set m0 to 12
  end if
  
  
–前月の月の長さ
  
set mLen0 to getMlen(y0, m0) of me
  
  
–前月のみ開始日の曜日を求めておく必要がある(3か月カレンダーを作るため)
  
set m0Date to (y0 & "/" & m0 & "/1 0:00:00") as text
  
set m0Date to date m0Date
  
set m0Day to getDay(m0Date) of me –1日の曜日
  
  
–翌月の情報を組み立てる
  
if m1 is not equal to 12 then
    –1〜11月の場合
    
set y2 to y1
    
set m2 to m1 + 1
  else
    –12月の場合
    
set y2 to y1 + 1
    
set m2 to 1
  end if
  
–翌月の月の長さ
  
set mLen2 to getMlen(y2, m2) of me
  
  
–3か月カレンダーの格納変数
  
set d3List to {}
  
–3か月カレンダーBの格納変数(当月の情報しか日付は入っていないカレンダー)
  
set d4List to {}
  
  
set gapList to {0, 0, 0, 0, 0, 0, 0}
  
set w1temp to items 1 thru (m0Day) of gapList
  
set w2temp to items 1 thru (m0Day) of gapList
  
  
set dayCounter to 1
  
  
–最初の1週目の要素を組み立てる
  
repeat with i from m0Day to 7
    set the end of w1temp to dayCounter
    
set the end of w2temp to 0
    
set dayCounter to dayCounter + 1
  end repeat
  
set the end of d3List to w1temp
  
set the end of d4List to w2temp
  
  
set w1temp to {}
  
set w2temp to {}
  
  
  
–前月の通常処理
  
repeat
    repeat with i from 1 to 7
      set the end of w1temp to dayCounter
      
set the end of w2temp to 0
      
      
set dayCounter to dayCounter + 1
      
if dayCounter > mLen0 then exit repeat
    end repeat
    
if dayCounter > mLen0 then exit repeat
    
set the end of d3List to w1temp
    
set the end of d4List to w2temp
    
    
set w1temp to {}
    
set w2temp to {}
    
  end repeat
  
  
–ここから当月処理
  
  
–1週目
  
if i = 7 then
    set ii to 1
    
set the end of d3List to w1temp
    
set the end of d4List to w2temp
    
set w1temp to {}
    
set w2temp to {}
    
  else
    set ii to i + 1
  end if
  
  
set dayCounter to 1 –日付カウンタの初期化
  
repeat with j from ii to 7
    set the end of w1temp to dayCounter
    
set the end of w2temp to dayCounter
    
    
set dayCounter to dayCounter + 1
  end repeat
  
  
set the end of d3List to w1temp
  
set the end of d4List to w2temp
  
  
set w1temp to {}
  
set w2temp to {}
  
  
–当月の2週目以降
  
repeat
    repeat with j from 1 to 7
      set the end of w1temp to dayCounter
      
set the end of w2temp to dayCounter
      
      
set dayCounter to dayCounter + 1
      
if dayCounter > mlen1 then exit repeat
    end repeat
    
if dayCounter > mlen1 then exit repeat
    
set the end of d3List to w1temp
    
set the end of d4List to w2temp
    
    
set w1temp to {}
    
set w2temp to {}
    
  end repeat
  
  
–ここから翌月処理
  
  
–1週目
  
if j = 7 then
    set iii to 1
    
set the end of d3List to w1temp
    
set the end of d4List to w2temp
    
    
set w1temp to {}
    
set w2temp to {}
    
  else
    set iii to j + 1
  end if
  
  
set dayCounter to 1 –日付カウンタの初期化
  
repeat with j from iii to 7
    set the end of w1temp to dayCounter
    
set the end of w2temp to 0
    
    
set dayCounter to dayCounter + 1
  end repeat
  
  
set the end of d3List to w1temp
  
set the end of d4List to w2temp
  
  
set w1temp to {}
  
set w2temp to {}
  
  
–翌月の2週目以降
  
repeat
    repeat with k from 1 to 7
      set the end of w1temp to dayCounter
      
set the end of w2temp to 0
      
      
set dayCounter to dayCounter + 1
      
if dayCounter > mlen1 then exit repeat
    end repeat
    
if dayCounter > mlen1 then exit repeat
    
set the end of d3List to w1temp
    
set the end of d4List to w2temp
    
    
set w1temp to {}
    
set w2temp to {}
    
  end repeat
  
  
if length of w1temp is not equal to 0 then
    set the end of d3List to w1temp
    
set the end of d4List to w2temp
    
  end if
  
  
  
–ここまで3か月カレンダーの生成
  
  
  
–3か月カレンダーにおいて今日が何週目かを算出
  
set weekCounter to 1
  
  
repeat with aWeek in d4List –裏リストで操作を行う
    –ただし、該当曜日しかチェックしないので全チェックに比べて速度7倍
    
set aDay to (item mXDay of aWeek) as number
    
if aDay = (d1 as number) then
      exit repeat
    end if
    
set weekCounter to weekCounter + 1
  end repeat
  
end makeCalendar

–現在日時から曜日を取得を返す
on getDay(aDate as date)
  return (weekday of aDate) as number
end getDay

–指定日の月のみ返す
on getMonth(aDat as date)
  return (month of aDat) as number
end getMonth

–指定日の日付のみ返す
on getDate(aDat as date)
  return (day of aDat) as number
end getDate

–指定日の年のみ返す
on getYear(aDat as date)
  return (year of aDat) as number
end getYear

–現在のカレンダーで指定年月の日数を返す(国際化対応版)
on getMlen(aYear as integer, aMonth as integer)
  set theNSCalendar to current application’s NSCalendar’s currentCalendar()
  
set theDate to theNSCalendar’s dateWithEra:1 |year|:aYear |month|:aMonth |day|:1 hour:0 minute:0 |second|:0 nanosecond:0
  
set theResult to theNSCalendar’s rangeOfUnit:(current application’s NSDayCalendarUnit) inUnit:(current application’s NSMonthCalendarUnit) forDate:theDate
  
return |length| of theResult
end getMlen

★Click Here to Open This Script 

Posted in Calendar Text | Tagged 10.11savvy 10.12savvy 10.13savvy Calendar | Leave a comment

ASOCでNSFontManagerのじっけん

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:ASOCでNSFontManagerのじっけん
— Created 2015-08-27 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

set aFontMan to current application’s NSFontManager’s sharedFontManager()’s availableFontFamilies()
–>  (NSArray) {​​​​​"01FLOPDESIGN", ​​​​​"A-OTF Shin Go Pr6N", ​​​​​"A-OTF Shin Go Pro", ​​​​​"Abadi MT Condensed Extra Bold", ​​​​​"Abadi MT Condensed Light", ​​​​​"AGENDAJinmeiGyoshotaiL1", ​​​​​"AGENDAJinmeiSeikaishotaiL1", ​​​​​"Akubin",….}

set aFontMan to current application’s NSFontManager’s sharedFontManager()’s availableMembersOfFontFamily:"MS Mincho"
–>  (NSArray) {​​​​​{​​​​​​​"MS-Mincho", ​​​​​​​"Regular", ​​​​​​​1, ​​​​​​​0​​​​​}​​​}

set aFontMan to current application’s NSFontManager’s sharedFontManager()’s availableMembersOfFontFamily:"Times"
–>  (NSArray) {​​​​​{​​​​​​​"Times-Roman", ​​​​​​​"Regular", ​​​​​​​1, ​​​​​​​0​​​​​}, ​​​​​{​​​​​​​"Times-Italic", ​​​​​​​"Italic", ​​​​​​​1, ​​​​​​​1​​​​​}, ​​​​​{​​​​​​​"Times-Bold", ​​​​​​​"Bold", ​​​​​​​1, ​​​​​​​2​​​​​}, ​​​​​{​​​​​​​"Times-BoldItalic", ​​​​​​​"Bold Italic", ​​​​​​​1, ​​​​​​​3​​​​​}​​​}

set aFontMan to current application’s NSFontManager’s sharedFontManager()’s localizedNameForFamily:"Osaka" face:"Regular-Mono"
–>  (NSString) "レギュラー−等幅"

★Click Here to Open This Script 

Posted in Font System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

インストールされているフォントをdisplay nameからキーワード検索 v3

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:インストールされているフォントをdisplay nameからキーワード検索 v3
— Created 2017-11-01 by Takaaki Naganoya
— Modified 2017-11-02 by Shane Stanley
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"
–http://piyocast.com/as/archives/4948

property NSFontManager : a reference to current application’s NSFontManager
property NSFont : a reference to current application’s NSFont
property NSPredicate : a reference to current application’s NSPredicate

set fRes to getEveryFontContainsAQueryStr("Helvetica") of me
–>  {"Helvetica", "Helvetica-Bold", "Helvetica-BoldOblique", "Helvetica-Light", "Helvetica-LightOblique", "Helvetica-Oblique", "HelveticaNeue", "HelveticaNeue-Bold", "HelveticaNeue-BoldItalic", "HelveticaNeue-CondensedBlack", "HelveticaNeue-CondensedBold", "HelveticaNeue-Italic", "HelveticaNeue-Light", "HelveticaNeue-LightItalic", "HelveticaNeue-Medium", "HelveticaNeue-MediumItalic", "HelveticaNeue-Thin", "HelveticaNeue-ThinItalic", "HelveticaNeue-UltraLight", "HelveticaNeue-UltraLightItalic"}

set fRes to getEveryFontContainsAQueryStr("ことり") of me
–>  {​​​​​"TheLittleBirdFONT", ​​​​​"kotorimojiFONT-TT"​​​}

on getEveryFontContainsAQueryStr(queryName as string)
  set hitFontList to {}
  
set aFontList to NSFontManager’s sharedFontManager()’s availableFonts()
  
— filter out hidden fonts
  
set thePred to NSPredicate’s predicateWithFormat:"NOT SELF BEGINSWITH ’.’"
  
set aFontList to aFontList’s filteredArrayUsingPredicate:thePred
  
  
repeat with fontName in aFontList
    set aFont to (NSFont’s fontWithName:fontName |size|:16)
    
set aDispFontName to (aFont’s displayName()) as string
    
    
if aDispFontName contains queryName then
      set end of hitFontList to (fontName as text)
    end if
  end repeat
  
  
return hitFontList
end getEveryFontContainsAQueryStr

★Click Here to Open This Script 

Posted in Font System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

フォントのPostScript NameからDisplayed Nameを取得

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:フォントのPostScript NameからDisplayed Nameを取得
— Created 2017-11-01 by Takaaki Naganoya
— Modified 2017-11-02 by Shane Stanley
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

property NSFontManager : a reference to current application’s NSFontManager
property NSFont : a reference to current application’s NSFont

set aName to "YuMin_36pKn-Medium"
set dName to getDisplayedNameOfFont(aName) of me
–>  "游明朝体+36ポかな ミディアム"

on getDisplayedNameOfFont(aName)
  set aFont to current application’s NSFont’s fontWithName:aName |size|:9.0
  
set aDispName to (aFont’s displayName()) as string
  
return aDispName
end getDisplayedNameOfFont

★Click Here to Open This Script 

Posted in Font System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

指定のフォントのグリフ数をカウント

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:指定のフォントのグリフ数をカウント
— Created 2016-02-01 by Takaaki Naganoya
— 2016 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"
use framework "AppKit"

set aFontName to "YuMin_36pKn-Medium"
set aRes to countNumberOfGlyphsInFont(aFontName) of me

–指定Postscript名称のフォントに定義されている文字数を数えて返す
on countNumberOfGlyphsInFont(fontName)
  set aFont to current application’s NSFont’s fontWithName:fontName |size|:9.0
  
if aFont = missing value then return false
  
set aProp to aFont’s numberOfGlyphs()
  
return aProp
end countNumberOfGlyphsInFont

★Click Here to Open This Script 

Posted in Font System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

言語コードから言語名を取得する

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:言語コードから言語名を取得する
— Created 2015-12-21 13:13:24 +0900 by Takaaki Naganoya
— 2015 Piyomaru Software
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set countryCode to "en"

set ident to current application’s NSLocale’s preferredLanguages()’s firstObject()
–>  (NSArray) {​​​​​"ja", ​​​​​"en-US", ​​​​​"en-GB", ​​​​​"en", ​​​​​"fr"​​​}
set aLocale to current application’s NSLocale’s alloc()’s initWithLocaleIdentifier:ident
set aCountryName to aLocale’s displayNameForKey:(current application’s NSLocaleIdentifier) value:countryCode
–>  (NSString) "英語 (アメリカ合衆国)"

★Click Here to Open This Script 

Posted in Language System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

現在のLocaleのIdentifier文字を取得する

Posted on 2月 6, 2018 by Takaaki Naganoya
AppleScript名:現在のLocaleのIdentifier文字を取得する
use AppleScript version "2.4"
use scripting additions
use framework "Foundation"

set aLoc to current application’s NSLocale’s currentLocale()’s identifier()
–>  (NSString) "ja_JP"

set aLoc to current application’s NSLocale’s systemLocale()
–>  (__NSCFLocale) <__NSCFLocale: 0x6180000f5480>

set isoCountry to current application’s NSLocale’s ISOCountryCodes()
–>  (NSArray) {​​​​​"AD", ​​​​​"AE", ​​​​​"AF", ​​​​​"AG", ​​​​​"AI", ​​​​​"AL", ​​​​​"AM", ​​​​​"AO", ​​​​​"AQ", ​​​​​"AR", ​​​​​"AS", ​​​​​"AT", ​​​​​"AU", ​​​​​"AW", ​​​​​"AX", ​​​​​"AZ", ​​​​​"BA", ​​​​​"BB", ​​​​​"BD", ​​​​​"BE", ​​​​​"BF", ​​​​​"BG", ​​​​​"BH", ​​​​​"BI", ​​​​​"BJ", ​​​​​"BL", ​​​​​"BM", ​​​​​"BN", ​​​​​"BO", ​​​​​"BQ", ​​​​​"BR", ​​​​​"BS", ​​​​​"BT", ​​​​​"BV", ​​​​​"BW", ​​​​​"BY", ​​​​​"BZ", ​​​​​"CA", ​​​​​"CC", ​​​​​"CD", ​​​​​"CF", ​​​​​"CG", ​​​​​"CH", ​​​​​"CI", ​​​​​"CK", ​​​​​"CL", ​​​​​"CM", ​​​​​"CN", ​​​​​"CO", ​​​​​"CR", ​​​​​"CU", ​​​​​"CV", ​​​​​"CW", ​​​​​"CX", ​​​​​"CY", ​​​​​"CZ", ​​​​​"DE", ​​​​​"DJ", ​​​​​"DK", ​​​​​"DM", ​​​​​"DO", ​​​​​"DZ", ​​​​​"EC", ​​​​​"EE", ​​​​​"EG", ​​​​​"EH", ​​​​​"ER", ​​​​​"ES", ​​​​​"ET", ​​​​​"FI", ​​​​​"FJ", ​​​​​"FK", ​​​​​"FM", ​​​​​"FO", ​​​​​"FR", ​​​​​"GA", ​​​​​"GB", ​​​​​"GD", ​​​​​"GE", ​​​​​"GF", ​​​​​"GG", ​​​​​"GH", ​​​​​"GI", ​​​​​"GL", ​​​​​"GM", ​​​​​"GN", ​​​​​"GP", ​​​​​"GQ", ​​​​​"GR", ​​​​​"GS", ​​​​​"GT", ​​​​​"GU", ​​​​​"GW", ​​​​​"GY", ​​​​​"HK", ​​​​​"HM", ​​​​​"HN", ​​​​​"HR", ​​​​​"HT", ​​​​​"HU", ​​​​​"ID", ​​​​​"IE", ​​​​​"IL", ​​​​​"IM", ​​​​​"IN", ​​​​​"IO", ​​​​​"IQ", ​​​​​"IR", ​​​​​"IS", ​​​​​"IT", ​​​​​"JE", ​​​​​"JM", ​​​​​"JO", ​​​​​"JP", ​​​​​"KE", ​​​​​"KG", ​​​​​"KH", ​​​​​"KI", ​​​​​"KM", ​​​​​"KN", ​​​​​"KP", ​​​​​"KR", ​​​​​"KW", ​​​​​"KY", ​​​​​"KZ", ​​​​​"LA", ​​​​​"LB", ​​​​​"LC", ​​​​​"LI", ​​​​​"LK", ​​​​​"LR", ​​​​​"LS", ​​​​​"LT", ​​​​​"LU", ​​​​​"LV", ​​​​​"LY", ​​​​​"MA", ​​​​​"MC", ​​​​​"MD", ​​​​​"ME", ​​​​​"MF", ​​​​​"MG", ​​​​​"MH", ​​​​​"MK", ​​​​​"ML", ​​​​​"MM", ​​​​​"MN", ​​​​​"MO", ​​​​​"MP", ​​​​​"MQ", ​​​​​"MR", ​​​​​"MS", ​​​​​"MT", ​​​​​"MU", ​​​​​"MV", ​​​​​"MW", ​​​​​"MX", ​​​​​"MY", ​​​​​"MZ", ​​​​​"NA", ​​​​​"NC", ​​​​​"NE", ​​​​​"NF", ​​​​​"NG", ​​​​​"NI", ​​​​​"NL", ​​​​​"NO", ​​​​​"NP", ​​​​​"NR", ​​​​​"NU", ​​​​​"NZ", ​​​​​"OM", ​​​​​"PA", ​​​​​"PE", ​​​​​"PF", ​​​​​"PG", ​​​​​"PH", ​​​​​"PK", ​​​​​"PL", ​​​​​"PM", ​​​​​"PN", ​​​​​"PR", ​​​​​"PS", ​​​​​"PT", ​​​​​"PW", ​​​​​"PY", ​​​​​"QA", ​​​​​"RE", ​​​​​"RO", ​​​​​"RS", ​​​​​"RU", ​​​​​"RW", ​​​​​"SA", ​​​​​"SB", ​​​​​"SC", ​​​​​"SD", ​​​​​"SE", ​​​​​"SG", ​​​​​"SH", ​​​​​"SI", ​​​​​"SJ", ​​​​​"SK", ​​​​​"SL", ​​​​​"SM", ​​​​​"SN", ​​​​​"SO", ​​​​​"SR", ​​​​​"SS", ​​​​​"ST", ​​​​​"SV", ​​​​​"SX", ​​​​​"SY", ​​​​​"SZ", ​​​​​"TC", ​​​​​"TD", ​​​​​"TF", ​​​​​"TG", ​​​​​"TH", ​​​​​"TJ", ​​​​​"TK", ​​​​​"TL", ​​​​​"TM", ​​​​​"TN", ​​​​​"TO", ​​​​​"TR", ​​​​​"TT", ​​​​​"TV", ​​​​​"TW", ​​​​​"TZ", ​​​​​"UA", ​​​​​"UG", ​​​​​"UM", ​​​​​"US", ​​​​​"UY", ​​​​​"UZ", ​​​​​"VA", ​​​​​"VC", ​​​​​"VE", ​​​​​"VG", ​​​​​"VI", ​​​​​"VN", ​​​​​"VU", ​​​​​"WF", ​​​​​"WS", ​​​​​"YE", ​​​​​"YT", ​​​​​"ZA", ​​​​​"ZM", ​​​​​"ZW"​​​}

set isoCurrency to current application’s NSLocale’s ISOCurrencyCodes()
–>  (NSArray) {​​​​​"ADP", ​​​​​"AED", ​​​​​"AFA", ​​​​​"AFN", ​​​​​"ALK", ​​​​​"ALL", ​​​​​"AMD", ​​​​​"ANG", ​​​​​"AOA", ​​​​​"AOK", ​​​​​"AON", ​​​​​"AOR", ​​​​​"ARA", ​​​​​"ARL", ​​​​​"ARM", ​​​​​"ARP", ​​​​​"ARS", ​​​​​"ATS", ​​​​​"AUD", ​​​​​"AWG", ​​​​​"AZM", ​​​​​"AZN", ​​​​​"BAD", ​​​​​"BAM", ​​​​​"BAN", ​​​​​"BBD", ​​​​​"BDT", ​​​​​"BEC", ​​​​​"BEF", ​​​​​"BEL", ​​​​​"BGL", ​​​​​"BGM", ​​​​​"BGN", ​​​​​"BGO", ​​​​​"BHD", ​​​​​"BIF", ​​​​​"BMD", ​​​​​"BND", ​​​​​"BOB", ​​​​​"BOL", ​​​​​"BOP", ​​​​​"BOV", ​​​​​"BRB", ​​​​​"BRC", ​​​​​"BRE", ​​​​​"BRL", ​​​​​"BRN", ​​​​​"BRR", ​​​​​"BRZ", ​​​​​"BSD", ​​​​​"BTN", ​​​​​"BUK", ​​​​​"BWP", ​​​​​"BYB", ​​​​​"BYR", ​​​​​"BZD", ​​​​​"CAD", ​​​​​"CDF", ​​​​​"CHE", ​​​​​"CHF", ​​​​​"CHW", ​​​​​"CLE", ​​​​​"CLF", ​​​​​"CLP", ​​​​​"CNX", ​​​​​"CNY", ​​​​​"COP", ​​​​​"COU", ​​​​​"CRC", ​​​​​"CSD", ​​​​​"CSK", ​​​​​"CUC", ​​​​​"CUP", ​​​​​"CVE", ​​​​​"CYP", ​​​​​"CZK", ​​​​​"DDM", ​​​​​"DEM", ​​​​​"DJF", ​​​​​"DKK", ​​​​​"DOP", ​​​​​"DZD", ​​​​​"ECS", ​​​​​"ECV", ​​​​​"EEK", ​​​​​"EGP", ​​​​​"EQE", ​​​​​"ERN", ​​​​​"ESA", ​​​​​"ESB", ​​​​​"ESP", ​​​​​"ETB", ​​​​​"EUR", ​​​​​"FIM", ​​​​​"FJD", ​​​​​"FKP", ​​​​​"FRF", ​​​​​"GBP", ​​​​​"GEK", ​​​​​"GEL", ​​​​​"GHC", ​​​​​"GHS", ​​​​​"GIP", ​​​​​"GMD", ​​​​​"GNF", ​​​​​"GNS", ​​​​​"GQE", ​​​​​"GRD", ​​​​​"GTQ", ​​​​​"GWE", ​​​​​"GWP", ​​​​​"GYD", ​​​​​"HKD", ​​​​​"HNL", ​​​​​"HRD", ​​​​​"HRK", ​​​​​"HTG", ​​​​​"HUF", ​​​​​"IDR", ​​​​​"IEP", ​​​​​"ILP", ​​​​​"ILR", ​​​​​"ILS", ​​​​​"INR", ​​​​​"IQD", ​​​​​"IRR", ​​​​​"ISJ", ​​​​​"ISK", ​​​​​"ITL", ​​​​​"JMD", ​​​​​"JOD", ​​​​​"JPY", ​​​​​"KES", ​​​​​"KGS", ​​​​​"KHR", ​​​​​"KMF", ​​​​​"KPW", ​​​​​"KRH", ​​​​​"KRO", ​​​​​"KRW", ​​​​​"KWD", ​​​​​"KYD", ​​​​​"KZT", ​​​​​"LAK", ​​​​​"LBP", ​​​​​"LKR", ​​​​​"LRD", ​​​​​"LSL", ​​​​​"LSM", ​​​​​"LTL", ​​​​​"LTT", ​​​​​"LUC", ​​​​​"LUF", ​​​​​"LUL", ​​​​​"LVL", ​​​​​"LVR", ​​​​​"LYD", ​​​​​"MAD", ​​​​​"MAF", ​​​​​"MCF", ​​​​​"MDC", ​​​​​"MDL", ​​​​​"MGA", ​​​​​"MGF", ​​​​​"MKD", ​​​​​"MKN", ​​​​​"MLF", ​​​​​"MMK", ​​​​​"MNT", ​​​​​"MOP", ​​​​​"MRO", ​​​​​"MTL", ​​​​​"MTP", ​​​​​"MUR", ​​​​​"MVP", ​​​​​"MVR", ​​​​​"MWK", ​​​​​"MXN", ​​​​​"MXP", ​​​​​"MXV", ​​​​​"MYR", ​​​​​"MZE", ​​​​​"MZM", ​​​​​"MZN", ​​​​​"NAD", ​​​​​"NGN", ​​​​​"NIC", ​​​​​"NIO", ​​​​​"NLG", ​​​​​"NOK", ​​​​​"NPR", ​​​​​"NZD", ​​​​​"OMR", ​​​​​"PAB", ​​​​​"PEI", ​​​​​"PEN", ​​​​​"PES", ​​​​​"PGK", ​​​​​"PHP", ​​​​​"PKR", ​​​​​"PLN", ​​​​​"PLZ", ​​​​​"PTE", ​​​​​"PYG", ​​​​​"QAR", ​​​​​"RHD", ​​​​​"ROL", ​​​​​"RON", ​​​​​"RSD", ​​​​​"RUB", ​​​​​"RUR", ​​​​​"RWF", ​​​​​"SAR", ​​​​​"SBD", ​​​​​"SCR", ​​​​​"SDD", ​​​​​"SDG", ​​​​​"SDP", ​​​​​"SEK", ​​​​​"SGD", ​​​​​"SHP", ​​​​​"SIT", ​​​​​"SKK", ​​​​​"SLL", ​​​​​"SOS", ​​​​​"SRD", ​​​​​"SRG", ​​​​​"SSP", ​​​​​"STD", ​​​​​"SUR", ​​​​​"SVC", ​​​​​"SYP", ​​​​​"SZL", ​​​​​"THB", ​​​​​"TJR", ​​​​​"TJS", ​​​​​"TMM", ​​​​​"TMT", ​​​​​"TND", ​​​​​"TOP", ​​​​​"TPE", ​​​​​"TRL", ​​​​​"TRY", ​​​​​"TTD", ​​​​​"TWD", ​​​​​"TZS", ​​​​​"UAH", ​​​​​"UAK", ​​​​​"UGS", ​​​​​"UGX", ​​​​​"USD", ​​​​​"USN", ​​​​​"USS", ​​​​​"UYI", ​​​​​"UYP", ​​​​​"UYU", ​​​​​"UZS", ​​​​​"VEB", ​​​​​"VEF", ​​​​​"VND", ​​​​​"VNN", ​​​​​"VUV", ​​​​​"WST", ​​​​​"XAF", ​​​​​"XAG", ​​​​​"XAU", ​​​​​"XBA", ​​​​​"XBB", ​​​​​"XBC", ​​​​​"XBD", ​​​​​"XCD", ​​​​​"XDR", ​​​​​"XEU", ​​​​​"XFO", ​​​​​"XFU", ​​​​​"XOF", ​​​​​"XPD", ​​​​​"XPF", ​​​​​"XPT", ​​​​​"XRE", ​​​​​"XSU", ​​​​​"XTS", ​​​​​"XUA", ​​​​​"XXX", ​​​​​"YDD", ​​​​​"YER", ​​​​​"YUD", ​​​​​"YUM", ​​​​​"YUN", ​​​​​"YUR", ​​​​​"ZAL", ​​​​​"ZAR", ​​​​​"ZMK", ​​​​​"ZMW", ​​​​​"ZRN", ​​​​​"ZRZ", ​​​​​"ZWL", ​​​​​"ZWR", ​​​​​"ZWD"​​​}

set aveLoc to current application’s NSLocale’s availableLocaleIdentifiers()
–>  (NSArray) {​​​​​"eu", ​​​​​"hr_BA", ​​​​​"en_CM", ​​​​​"rw_RW", ​​​​​"en_SZ", ​​​​​"tk_Latn", ​​​​​"uz_Arab", ​​​​​"he_IL", ​​​​​"ar", ​​​​​"en_PN", ​​​​​"as", ​​​​​"en_NF", ​​​​​"rwk_TZ", ​​​​​"zh_Hant_TW", ​​​​​"gsw_LI", ​​​​​"th_TH", ​​​​​"ta_IN", ​​​​​"es_EA", ​​​​​"fr_GF", ​​​​​"ar_001", ​​​​​"en_RW", ​​​​​"tr_TR", ​​​​​"de_CH", ​​​​​"ee_TG", ​​​​​"en_NG", ​​​​​"fr_TG", ​​​​​"az", ​​​​​"fr_SC", ​​​​​"es_HN", ​​​​​"en_AG", ​​​​​"ru_KZ", ​​​​​"gsw", ​​​​​"dyo", ​​​​​"so_ET", ​​​​​"zh_Hant_MO", ​​​​​"de_BE", ​​​​​"km_KH", ​​​​​"my_MM", ​​​​​"mgh_MZ", ​​​​​"ee_GH", ​​​​​"es_EC", ​​​​​"kw_GB", ​​​​​"rm_CH", ​​​​​"en_ME", ​​​​​"nyn", ​​​​​"mk_MK", ​​​​​"bs_Cyrl_BA", ​​​​​"ar_MR", ​​​​​"en_BM", ​​​​​"ms_Arab", ​​​​​"en_AI", ​​​​​"gl_ES", ​​​​​"en_PR", ​​​​​"ha_Latn_GH", ​​​​​"ne_IN", ​​​​​"or_IN", ​​​​​"khq_ML", ​​​​​"en_MG", ​​​​​"pt_TL", ​​​​​"en_LC", ​​​​​"ta_SG", ​​​​​"jmc_TZ", ​​​​​"om_ET", ​​​​​"lv_LV", ​​​​​"es_US", ​​​​​"en_PT", ​​​​​"vai_Latn_LR", ​​​​​"to_TO", ​​​​​"en_NL", ​​​​​"cgg_UG", ​​​​​"ta", ​​​​​"en_MH", ​​​​​"iu_Cans_CA", ​​​​​"zu_ZA", ​​​​​"shi_Latn_MA", ​​​​​"brx_IN", ​​​​​"ar_KM", ​​​​​"en_AL", ​​​​​"te", ​​​​​"chr_US", ​​​​​"yo_BJ", ​​​​​"fr_VU", ​​​​​"pa", ​​​​​"tg", ​​​​​"ks_Arab", ​​​​​"kea", ​​​​​"te_IN", ​​​​​"th", ​​​​​"fr_RE", ​​​​​"ur_IN", ​​​​​"yo_NG", ​​​​​"ti", ​​​​​"guz_KE", ​​​​​"tk", ​​​​​"kl_GL", ​​​​​"ksf_CM", ​​​​​"mua_CM", ​​​​​"lag_TZ", ​​​​​"fr_TN", ​​​​​"es_PA", ​​​​​"pl_PL", ​​​​​"to", ​​​​​"hi_IN", ​​​​​"dje_NE", ​​​​​"es_GQ", ​​​​​"kok_IN", ​​​​​"pl", ​​​​​"tr", ​​​​​"bem", ​​​​​"ha", ​​​​​"ckb", ​​​​​"lg", ​​​​​"fr_GN", ​​​​​"en_PW", ​​​​​"en_NO", ​​​​​"nyn_UG", ​​​​​"sr_Latn_RS", ​​​​​"pa_Guru", ​​​​​"he", ​​​​​"swc_CD", ​​​​​"ug_Arab", ​​​​​"lu_CD", ​​​​​"mgo_CM", ​​​​​"sn_ZW", ​​​​​"en_BS", ​​​​​"ps_AF", ​​​​​"da", ​​​​​"ms_Latn_SG", ​​​​​"ps", ​​​​​"ln", ​​​​​"pt", ​​​​​"iu_Cans", ​​​​​"hi", ​​​​​"lo", ​​​​​"ebu", ​​​​​"de", ​​​​​"gu_IN", ​​​​​"seh", ​​​​​"en_CX", ​​​​​"en_ZM", ​​​​​"tzm_Latn_MA", ​​​​​"fr_HT", ​​​​​"fr_GP", ​​​​​"lt", ​​​​​"lu", ​​​​​"ln_CD", ​​​​​"vai_Latn", ​​​​​"el_GR", ​​​​​"lv", ​​​​​"en_KE", ​​​​​"sbp", ​​​​​"hr", ​​​​​"en_CY", ​​​​​"es_GT", ​​​​​"twq_NE", ​​​​​"zh_Hant_HK", ​​​​​"kln_KE", ​​​​​"fr_GQ", ​​​​​"chr", ​​​​​"hu", ​​​​​"es_UY", ​​​​​"fr_CA", ​​​​​"en_NR", ​​​​​"mer", ​​​​​"shi", ​​​​​"es_PE", ​​​​​"fr_SN", ​​​​​"bez", ​​​​​"sw_TZ", ​​​​​"kkj", ​​​​​"hy", ​​​​​"kk_Cyrl_KZ", ​​​​​"en_CZ", ​​​​​"teo_KE", ​​​​​"teo", ​​​​​"dz_BT", ​​​​​"ar_JO", ​​​​​"mer_KE", ​​​​​"khq", ​​​​​"ln_CF", ​​​​​"nn_NO", ​​​​​"en_MO", ​​​​​"ar_TD", ​​​​​"dz", ​​​​​"ses", ​​​​​"en_BW", ​​​​​"en_AS", ​​​​​"ar_IL", ​​​​​"ms_Latn_BN", ​​​​​"bo_CN", ​​​​​"nnh", ​​​​​"teo_UG", ​​​​​"hy_AM", ​​​​​"ln_CG", ​​​​​"sr_Latn_BA", ​​​​​"en_MP", ​​​​​"ksb_TZ", ​​​​​"ar_SA", ​​​​​"ar_LY", ​​​​​"en_AT", ​​​​​"so_KE", ​​​​​"fr_CD", ​​​​​"af_NA", ​​​​​"en_NU", ​​​​​"es_PH", ​​​​​"en_KI", ​​​​​"en_JE", ​​​​​"lkt", ​​​​​"en_AU", ​​​​​"fa_IR", ​​​​​"uz_Latn_UZ", ​​​​​"ky_Cyrl", ​​​​​"zh_Hans_CN", ​​​​​"ewo_CM", ​​​​​"fr_PF", ​​​​​"ca_IT", ​​​​​"en_BZ", ​​​​​"ar_KW", ​​​​​"pt_GW", ​​​​​"fr_FR", ​​​​​"am_ET", ​​​​​"en_VC", ​​​​​"fr_DJ", ​​​​​"fr_CF", ​​​​​"es_SV", ​​​​​"en_MS", ​​​​​"pt_ST", ​​​​​"ar_SD", ​​​​​"luy_KE", ​​​​​"swc", ​​​​​"de_LI", ​​​​​"fr_CG", ​​​​​"zh_Hans_SG", ​​​​​"en_MT", ​​​​​"ewo", ​​​​​"af_ZA", ​​​​​"om_KE", ​​​​​"nl_SR", ​​​​​"es_ES", ​​​​​"es_DO", ​​​​​"ar_IQ", ​​​​​"fr_CH", ​​​​​"nnh_CM", ​​​​​"es_419", ​​​​​"en_MU", ​​​​​"en_US_POSIX", ​​​​​"yav_CM", ​​​​​"luo_KE", ​​​​​"dua_CM", ​​​​​"et_EE", ​​​​​"en_IE", ​​​​​"ak_GH", ​​​​​"rwk", ​​​​​"es_CL", ​​​​​"kea_CV", ​​​​​"fr_CI", ​​​​​"fr_BE", ​​​​​"en_NZ", ​​​​​"ky_Cyrl_KG", ​​​​​"en_LR", ​​​​​"en_KN", ​​​​​"nb_SJ", ​​​​​"sg", ​​​​​"sr_Cyrl_RS", ​​​​​"ru_RU", ​​​​​"en_ZW", ​​​​​"sv_AX", ​​​​​"si", ​​​​​"ga_IE", ​​​​​"en_VG", ​​​​​"sk", ​​​​​"agq_CM", ​​​​​"fr_BF", ​​​​​"naq_NA", ​​​​​"sl", ​​​​​"en_MW", ​​​​​"mr_IN", ​​​​​"az_Latn", ​​​​​"en_LS", ​​​​​"de_AT", ​​​​​"ka", ​​​​​"sn", ​​​​​"sr_Latn_ME", ​​​​​"fr_NC", ​​​​​"so", ​​​​​"is_IS", ​​​​​"twq", ​​​​​"ig_NG", ​​​​​"sq", ​​​​​"fo_FO", ​​​​​"sr", ​​​​​"tzm", ​​​​​"ga", ​​​​​"om", ​​​​​"en_LT", ​​​​​"bas_CM", ​​​​​"ki", ​​​​​"nl_BE", ​​​​​"ar_QA", ​​​​​"sv", ​​​​​"kk", ​​​​​"sw", ​​​​​"es_CO", ​​​​​"az_Latn_AZ", ​​​​​"rn_BI", ​​​​​"or", ​​​​​"kl", ​​​​​"ca", ​​​​​"en_VI", ​​​​​"km", ​​​​​"kn", ​​​​​"en_LU", ​​​​​"fr_SY", ​​​​​"ar_TN", ​​​​​"en_JM", ​​​​​"fr_PM", ​​​​​"ko", ​​​​​"fr_NE", ​​​​​"fr_MA", ​​​​​"gl", ​​​​​"ru_MD", ​​​​​"saq_KE", ​​​​​"ks", ​​​​​"fr_CM", ​​​​​"gv_IM", ​​​​​"fr_BI", ​​​​​"en_LV", ​​​​​"ks_Arab_IN", ​​​​​"es_NI", ​​​​​"en_GB", ​​​​​"kw", ​​​​​"nl_SX", ​​​​​"dav_KE", ​​​​​"tr_CY", ​​​​​"ky", ​​​​​"en_UG", ​​​​​"tzm_Latn", ​​​​​"en_TC", ​​​​​"nus_SD", ​​​​​"ar_EG", ​​​​​"fr_BJ", ​​​​​"gu", ​​​​​"es_PR", ​​​​​"fr_RW", ​​​​​"sr_Cyrl_BA", ​​​​​"gv", ​​​​​"fr_MC", ​​​​​"cs", ​​​​​"bez_TZ", ​​​​​"es_CR", ​​​​​"asa_TZ", ​​​​​"ar_EH", ​​​​​"ms_Arab_BN", ​​​​​"mn_Cyrl", ​​​​​"sbp_TZ", ​​​​​"ha_Latn_NE", ​​​​​"lt_LT", ​​​​​"mfe", ​​​​​"en_GD", ​​​​​"cy", ​​​​​"ca_FR", ​​​​​"es_BO", ​​​​​"fr_BL", ​​​​​"bn_IN", ​​​​​"uz_Cyrl_UZ", ​​​​​"az_Cyrl", ​​​​​"en_IM", ​​​​​"sw_KE", ​​​​​"en_SB", ​​​​​"ur_PK", ​​​​​"pa_Arab", ​​​​​"haw_US", ​​​​​"ar_SO", ​​​​​"en_IN", ​​​​​"ha_Latn", ​​​​​"fil", ​​​​​"fr_MF", ​​​​​"en_WS", ​​​​​"es_CU", ​​​​​"ja_JP", ​​​​​"en_SC", ​​​​​"en_IO", ​​​​​"pt_PT", ​​​​​"en_HK", ​​​​​"en_GG", ​​​​​"fr_MG", ​​​​​"de_LU", ​​​​​"ms_Latn_MY", ​​​​​"tg_Cyrl", ​​​​​"en_SD", ​​​​​"shi_Tfng", ​​​​​"ln_AO", ​​​​​"ug_Arab_CN", ​​​​​"as_IN", ​​​​​"en_GH", ​​​​​"ro_RO", ​​​​​"jgo_CM", ​​​​​"dua", ​​​​​"en_UM", ​​​​​"en_SE", ​​​​​"kn_IN", ​​​​​"en_KY", ​​​​​"vun_TZ", ​​​​​"kln", ​​​​​"en_GI", ​​​​​"ca_ES", ​​​​​"rof", ​​​​​"pt_CV", ​​​​​"kok", ​​​​​"pt_BR", ​​​​​"ar_DJ", ​​​​​"zh", ​​​​​"fi_FI", ​​​​​"tg_Cyrl_TJ", ​​​​​"es_PY", ​​​​​"ar_SS", ​​​​​"mua", ​​​​​"sr_Cyrl_ME", ​​​​​"vai_Vaii_LR", ​​​​​"en_001", ​​​​​"xog_UG", ​​​​​"en_TK", ​​​​​"si_LK", ​​​​​"en_SG", ​​​​​"nl_NL", ​​​​​"vi", ​​​​​"sv_SE", ​​​​​"pt_AO", ​​​​​"fr_DZ", ​​​​​"ca_AD", ​​​​​"xog", ​​​​​"en_IS", ​​​​​"nb", ​​​​​"seh_MZ", ​​​​​"es_AR", ​​​​​"sk_SK", ​​​​​"en_SH", ​​​​​"ti_ER", ​​​​​"nd", ​​​​​"az_Cyrl_AZ", ​​​​​"zu", ​​​​​"ne", ​​​​​"nd_ZW", ​​​​​"el_CY", ​​​​​"en_IT", ​​​​​"nl_BQ", ​​​​​"da_GL", ​​​​​"ja", ​​​​​"rm", ​​​​​"fr_ML", ​​​​​"rn", ​​​​​"en_VU", ​​​​​"rof_TZ", ​​​​​"ro", ​​​​​"ebu_KE", ​​​​​"ru_KG", ​​​​​"en_SI", ​​​​​"sg_CF", ​​​​​"mfe_MU", ​​​​​"nl", ​​​​​"brx", ​​​​​"bs_Latn", ​​​​​"fa", ​​​​​"zgh_MA", ​​​​​"en_GM", ​​​​​"shi_Latn", ​​​​​"en_FI", ​​​​​"nn", ​​​​​"en_EE", ​​​​​"ru", ​​​​​"kam_KE", ​​​​​"vai_Vaii", ​​​​​"ar_ER", ​​​​​"ti_ET", ​​​​​"rw", ​​​​​"ff", ​​​​​"luo", ​​​​​"fa_AF", ​​​​​"ha_Latn_NG", ​​​​​"nl_CW", ​​​​​"en_HR", ​​​​​"en_FJ", ​​​​​"fi", ​​​​​"pt_MO", ​​​​​"be", ​​​​​"en_US", ​​​​​"en_TO", ​​​​​"en_SK", ​​​​​"bg", ​​​​​"ru_BY", ​​​​​"it_IT", ​​​​​"ml_IN", ​​​​​"gsw_CH", ​​​​​"fo", ​​​​​"sv_FI", ​​​​​"en_FK", ​​​​​"nus", ​​​​​"ta_LK", ​​​​​"vun", ​​​​​"sr_Latn", ​​​​​"fr", ​​​​​"en_SL", ​​​​​"bm", ​​​​​"ar_BH", ​​​​​"guz", ​​​​​"bn", ​​​​​"bo", ​​​​​"ar_SY", ​​​​​"lo_LA", ​​​​​"ne_NP", ​​​​​"uz_Latn", ​​​​​"be_BY", ​​​​​"es_IC", ​​​​​"sr_Latn_XK", ​​​​​"ar_MA", ​​​​​"pa_Guru_IN", ​​​​​"br", ​​​​​"luy", ​​​​​"kde_TZ", ​​​​​"bs", ​​​​​"hu_HU", ​​​​​"ar_AE", ​​​​​"en_HU", ​​​​​"zh_Hans", ​​​​​"en_FM", ​​​​​"sq_AL", ​​​​​"ko_KP", ​​​​​"en_150", ​​​​​"en_DE", ​​​​​"fr_MQ", ​​​​​"en_CA", ​​​​​"en_TR", ​​​​​"ro_MD", ​​​​​"es_VE", ​​​​​"fr_WF", ​​​​​"mt_MT", ​​​​​"kab", ​​​​​"nmg_CM", ​​​​​"ru_UA", ​​​​​"fr_MR", ​​​​​"tk_Latn_TM", ​​​​​"zh_Hans_MO", ​​​​​"mn_Cyrl_MN", ​​​​​"bs_Cyrl", ​​​​​"sw_UG", ​​​​​"ko_KR", ​​​​​"en_DG", ​​​​​"bo_IN", ​​​​​"en_CC", ​​​​​"shi_Tfng_MA", ​​​​​"lag", ​​​​​"it_SM", ​​​​​"en_TT", ​​​​​"ms_Arab_MY", ​​​​​"sq_MK", ​​​​​"ms_Latn", ​​​​​"bem_ZM", ​​​​​"kde", ​​​​​"ar_OM", ​​​​​"cgg", ​​​​​"bas", ​​​​​"kam", ​​​​​"zh_Hant", ​​​​​"es_MX", ​​​​​"en_GU", ​​​​​"fr_MU", ​​​​​"fr_KM", ​​​​​"ar_LB", ​​​​​"en_BA", ​​​​​"en_TV", ​​​​​"sr_Cyrl", ​​​​​"dje", ​​​​​"kab_DZ", ​​​​​"fil_PH", ​​​​​"vai", ​​​​​"hr_HR", ​​​​​"bs_Latn_BA", ​​​​​"nl_AW", ​​​​​"dav", ​​​​​"so_SO", ​​​​​"ar_PS", ​​​​​"en_FR", ​​​​​"uz_Cyrl", ​​​​​"ff_SN", ​​​​​"en_BB", ​​​​​"ki_KE", ​​​​​"naq", ​​​​​"en_SS", ​​​​​"mg_MG", ​​​​​"mas_KE", ​​​​​"en_RO", ​​​​​"en_PG", ​​​​​"mgh", ​​​​​"dyo_SN", ​​​​​"mas", ​​​​​"agq", ​​​​​"bn_BD", ​​​​​"haw", ​​​​​"nb_NO", ​​​​​"da_DK", ​​​​​"en_DK", ​​​​​"saq", ​​​​​"ug", ​​​​​"cy_GB", ​​​​​"fr_YT", ​​​​​"jmc", ​​​​​"ses_ML", ​​​​​"en_PH", ​​​​​"de_DE", ​​​​​"ar_YE", ​​​​​"bm_ML", ​​​​​"yo", ​​​​​"lkt_US", ​​​​​"uz_Arab_AF", ​​​​​"jgo", ​​​​​"uk", ​​​​​"sl_SI", ​​​​​"en_CH", ​​​​​"asa", ​​​​​"lg_UG", ​​​​​"mgo", ​​​​​"id_ID", ​​​​​"en_NA", ​​​​​"en_GY", ​​​​​"zgh", ​​​​​"pt_MZ", ​​​​​"fr_LU", ​​​​​"kk_Cyrl", ​​​​​"mas_TZ", ​​​​​"ur", ​​​​​"en_DM", ​​​​​"ta_MY", ​​​​​"en_BE", ​​​​​"mg", ​​​​​"fr_GA", ​​​​​"ka_GE", ​​​​​"nmg", ​​​​​"en_TZ", ​​​​​"eu_ES", ​​​​​"ar_DZ", ​​​​​"id", ​​​​​"so_DJ", ​​​​​"yav", ​​​​​"mk", ​​​​​"pa_Arab_PK", ​​​​​"ml", ​​​​​"en_ER", ​​​​​"ig", ​​​​​"mn", ​​​​​"ksb", ​​​​​"uz", ​​​​​"vi_VN", ​​​​​"ii", ​​​​​"en_PK", ​​​​​"ee", ​​​​​"mr", ​​​​​"ms", ​​​​​"en_ES", ​​​​​"sq_XK", ​​​​​"it_CH", ​​​​​"mt", ​​​​​"en_CK", ​​​​​"br_FR", ​​​​​"sr_Cyrl_XK", ​​​​​"ksf", ​​​​​"en_SX", ​​​​​"bg_BG", ​​​​​"en_PL", ​​​​​"af", ​​​​​"el", ​​​​​"cs_CZ", ​​​​​"fr_TD", ​​​​​"zh_Hans_HK", ​​​​​"is", ​​​​​"my", ​​​​​"en", ​​​​​"it", ​​​​​"ii_CN", ​​​​​"eo", ​​​​​"iu", ​​​​​"en_ZA", ​​​​​"en_AD", ​​​​​"ak", ​​​​​"en_RU", ​​​​​"kkj_CM", ​​​​​"am", ​​​​​"es", ​​​​​"et", ​​​​​"uk_UA"​​​}

set isoLang to current application’s NSLocale’s ISOLanguageCodes()
–>  (NSArray) {​​​​​"aa", ​​​​​"ab", ​​​​​"ace", ​​​​​"ach", ​​​​​"ada", ​​​​​"ady", ​​​​​"ae", ​​​​​"af", ​​​​​"afa", ​​​​​"afh", ​​​​​"agq", ​​​​​"ain", ​​​​​"ak", ​​​​​"akk", ​​​​​"ale", ​​​​​"alg", ​​​​​"alt", ​​​​​"am", ​​​​​"an", ​​​​​"ang", ​​​​​"anp", ​​​​​"apa", ​​​​​"ar", ​​​​​"arc", ​​​​​"arn", ​​​​​"arp", ​​​​​"art", ​​​​​"arw", ​​​​​"as", ​​​​​"asa", ​​​​​"ast", ​​​​​"ath", ​​​​​"aus", ​​​​​"av", ​​​​​"awa", ​​​​​"ay", ​​​​​"az", ​​​​​"ba", ​​​​​"bad", ​​​​​"bai", ​​​​​"bal", ​​​​​"ban", ​​​​​"bas", ​​​​​"bat", ​​​​​"bax", ​​​​​"bbj", ​​​​​"be", ​​​​​"bej", ​​​​​"bem", ​​​​​"ber", ​​​​​"bez", ​​​​​"bfd", ​​​​​"bg", ​​​​​"bh", ​​​​​"bho", ​​​​​"bi", ​​​​​"bik", ​​​​​"bin", ​​​​​"bkm", ​​​​​"bla", ​​​​​"bm", ​​​​​"bn", ​​​​​"bnt", ​​​​​"bo", ​​​​​"br", ​​​​​"bra", ​​​​​"brx", ​​​​​"bs", ​​​​​"bss", ​​​​​"btk", ​​​​​"bua", ​​​​​"bug", ​​​​​"bum", ​​​​​"byn", ​​​​​"byv", ​​​​​"ca", ​​​​​"cad", ​​​​​"cai", ​​​​​"car", ​​​​​"cau", ​​​​​"cay", ​​​​​"cch", ​​​​​"ce", ​​​​​"ceb", ​​​​​"cel", ​​​​​"cgg", ​​​​​"ch", ​​​​​"chb", ​​​​​"chg", ​​​​​"chk", ​​​​​"chm", ​​​​​"chn", ​​​​​"cho", ​​​​​"chp", ​​​​​"chr", ​​​​​"chy", ​​​​​"ckb", ​​​​​"cmc", ​​​​​"co", ​​​​​"cop", ​​​​​"cpe", ​​​​​"cpf", ​​​​​"cpp", ​​​​​"cr", ​​​​​"crh", ​​​​​"crp", ​​​​​"cs", ​​​​​"csb", ​​​​​"cu", ​​​​​"cus", ​​​​​"cv", ​​​​​"cy", ​​​​​"da", ​​​​​"dak", ​​​​​"dar", ​​​​​"dav", ​​​​​"day", ​​​​​"de", ​​​​​"del", ​​​​​"den", ​​​​​"dgr", ​​​​​"din", ​​​​​"dje", ​​​​​"doi", ​​​​​"dra", ​​​​​"dsb", ​​​​​"dua", ​​​​​"dum", ​​​​​"dv", ​​​​​"dyo", ​​​​​"dyu", ​​​​​"dz", ​​​​​"dzg", ​​​​​"ebu", ​​​​​"ee", ​​​​​"efi", ​​​​​"egy", ​​​​​"eka", ​​​​​"el", ​​​​​"elx", ​​​​​"en", ​​​​​"enm", ​​​​​"eo", ​​​​​"es", ​​​​​"et", ​​​​​"eu", ​​​​​"ewo", ​​​​​"fa", ​​​​​"fan", ​​​​​"fat", ​​​​​"ff", ​​​​​"fi", ​​​​​"fil", ​​​​​"fiu", ​​​​​"fj", ​​​​​"fo", ​​​​​"fon", ​​​​​"fr", ​​​​​"frm", ​​​​​"fro", ​​​​​"frr", ​​​​​"frs", ​​​​​"fur", ​​​​​"fy", ​​​​​"ga", ​​​​​"gaa", ​​​​​"gay", ​​​​​"gba", ​​​​​"gd", ​​​​​"gem", ​​​​​"gez", ​​​​​"gil", ​​​​​"gl", ​​​​​"gmh", ​​​​​"gn", ​​​​​"goh", ​​​​​"gon", ​​​​​"gor", ​​​​​"got", ​​​​​"grb", ​​​​​"grc", ​​​​​"gsw", ​​​​​"gu", ​​​​​"guz", ​​​​​"gv", ​​​​​"gwi", ​​​​​"ha", ​​​​​"hai", ​​​​​"haw", ​​​​​"he", ​​​​​"hi", ​​​​​"hil", ​​​​​"him", ​​​​​"hit", ​​​​​"hmn", ​​​​​"ho", ​​​​​"hr", ​​​​​"hsb", ​​​​​"ht", ​​​​​"hu", ​​​​​"hup", ​​​​​"hy", ​​​​​"hz", ​​​​​"ia", ​​​​​"iba", ​​​​​"ibb", ​​​​​"id", ​​​​​"ie", ​​​​​"ig", ​​​​​"ii", ​​​​​"ijo", ​​​​​"ik", ​​​​​"ilo", ​​​​​"inc", ​​​​​"ine", ​​​​​"inh", ​​​​​"io", ​​​​​"ira", ​​​​​"iro", ​​​​​"is", ​​​​​"it", ​​​​​"iu", ​​​​​"ja", ​​​​​"jbo", ​​​​​"jgo", ​​​​​"jmc", ​​​​​"jpr", ​​​​​"jrb", ​​​​​"jv", ​​​​​"ka", ​​​​​"kaa", ​​​​​"kab", ​​​​​"kac", ​​​​​"kaj", ​​​​​"kam", ​​​​​"kar", ​​​​​"kaw", ​​​​​"kbd", ​​​​​"kbl", ​​​​​"kcg", ​​​​​"kde", ​​​​​"kea", ​​​​​"kfo", ​​​​​"kg", ​​​​​"kha", ​​​​​"khi", ​​​​​"kho", ​​​​​"khq", ​​​​​"ki", ​​​​​"kj", ​​​​​"kk", ​​​​​"kkj", ​​​​​"kl", ​​​​​"kln", ​​​​​"km", ​​​​​"kmb", ​​​​​"kn", ​​​​​"ko", ​​​​​"kok", ​​​​​"kos", ​​​​​"kpe", ​​​​​"kr", ​​​​​"krc", ​​​​​"krl", ​​​​​"kro", ​​​​​"kru", ​​​​​"ks", ​​​​​"ksb", ​​​​​"ksf", ​​​​​"ksh", ​​​​​"ku", ​​​​​"kum", ​​​​​"kut", ​​​​​"kv", ​​​​​"kw", ​​​​​"ky", ​​​​​"la", ​​​​​"lad", ​​​​​"lag", ​​​​​"lah", ​​​​​"lam", ​​​​​"lb", ​​​​​"lez", ​​​​​"lg", ​​​​​"li", ​​​​​"lkt", ​​​​​"ln", ​​​​​"lo", ​​​​​"lol", ​​​​​"loz", ​​​​​"lt", ​​​​​"lu", ​​​​​"lua", ​​​​​"lui", ​​​​​"lun", ​​​​​"luo", ​​​​​"lus", ​​​​​"luy", ​​​​​"lv", ​​​​​"mad", ​​​​​"maf", ​​​​​"mag", ​​​​​"mai", ​​​​​"mak", ​​​​​"man", ​​​​​"map", ​​​​​"mas", ​​​​​"mde", ​​​​​"mdf", ​​​​​"mdr", ​​​​​"men", ​​​​​"mer", ​​​​​"mfe", ​​​​​"mg", ​​​​​"mga", ​​​​​"mgh", ​​​​​"mgo", ​​​​​"mh", ​​​​​"mi", ​​​​​"mic", ​​​​​"min", ​​​​​"mis", ​​​​​"mk", ​​​​​"mkh", ​​​​​"ml", ​​​​​"mn", ​​​​​"mnc", ​​​​​"mni", ​​​​​"mno", ​​​​​"mo", ​​​​​"moh", ​​​​​"mos", ​​​​​"mr", ​​​​​"ms", ​​​​​"mt", ​​​​​"mua", ​​​​​"mul", ​​​​​"mun", ​​​​​"mus", ​​​​​"mwl", ​​​​​"mwr", ​​​​​"my", ​​​​​"mye", ​​​​​"myn", ​​​​​"myv", ​​​​​"na", ​​​​​"nah", ​​​​​"nai", ​​​​​"nap", ​​​​​"naq", ​​​​​"nb", ​​​​​"nd", ​​​​​"nds", ​​​​​"ne", ​​​​​"new", ​​​​​"ng", ​​​​​"nia", ​​​​​"nic", ​​​​​"niu", ​​​​​"nl", ​​​​​"nmg", ​​​​​"nn", ​​​​​"nnh", ​​​​​"no", ​​​​​"nog", ​​​​​"non", ​​​​​"nqo", ​​​​​"nr", ​​​​​"nso", ​​​​​"nub", ​​​​​"nus", ​​​​​"nv", ​​​​​"nwc", ​​​​​"ny", ​​​​​"nym", ​​​​​"nyn", ​​​​​"nyo", ​​​​​"nzi", ​​​​​"oc", ​​​​​"oj", ​​​​​"om", ​​​​​"or", ​​​​​"os", ​​​​​"osa", ​​​​​"ota", ​​​​​"oto", ​​​​​"pa", ​​​​​"paa", ​​​​​"pag", ​​​​​"pal", ​​​​​"pam", ​​​​​"pap", ​​​​​"pau", ​​​​​"peo", ​​​​​"phi", ​​​​​"phn", ​​​​​"pi", ​​​​​"pl", ​​​​​"pon", ​​​​​"pra", ​​​​​"pro", ​​​​​"ps", ​​​​​"pt", ​​​​​"qu", ​​​​​"raj", ​​​​​"rap", ​​​​​"rar", ​​​​​"rm", ​​​​​"rn", ​​​​​"ro", ​​​​​"roa", ​​​​​"rof", ​​​​​"rom", ​​​​​"ru", ​​​​​"rup", ​​​​​"rw", ​​​​​"rwk", ​​​​​"sa", ​​​​​"sad", ​​​​​"sah", ​​​​​"sai", ​​​​​"sal", ​​​​​"sam", ​​​​​"saq", ​​​​​"sas", ​​​​​"sat", ​​​​​"sba", ​​​​​"sbp", ​​​​​"sc", ​​​​​"scn", ​​​​​"sco", ​​​​​"sd", ​​​​​"se", ​​​​​"see", ​​​​​"seh", ​​​​​"sel", ​​​​​"sem", ​​​​​"ses", ​​​​​"sg", ​​​​​"sga", ​​​​​"sgn", ​​​​​"shi", ​​​​​"shn", ​​​​​"shu", ​​​​​"si", ​​​​​"sid", ​​​​​"sio", ​​​​​"sit", ​​​​​"sk", ​​​​​"sl", ​​​​​"sla", ​​​​​"sm", ​​​​​"sma", ​​​​​"smi", ​​​​​"smj", ​​​​​"smn", ​​​​​"sms", ​​​​​"sn", ​​​​​"snk", ​​​​​"so", ​​​​​"sog", ​​​​​"son", ​​​​​"sq", ​​​​​"sr", ​​​​​"srn", ​​​​​"srr", ​​​​​"ss", ​​​​​"ssa", ​​​​​"ssy", ​​​​​"st", ​​​​​"su", ​​​​​"suk", ​​​​​"sus", ​​​​​"sux", ​​​​​"sv", ​​​​​"sw", ​​​​​"swb", ​​​​​"swc", ​​​​​"syc", ​​​​​"syr", ​​​​​"ta", ​​​​​"tai", ​​​​​"te", ​​​​​"tem", ​​​​​"teo", ​​​​​"ter", ​​​​​"tet", ​​​​​"tg", ​​​​​"th", ​​​​​"ti", ​​​​​"tig", ​​​​​"tiv", ​​​​​"tk", ​​​​​"tkl", ​​​​​"tl", ​​​​​"tlh", ​​​​​"tli", ​​​​​"tmh", ​​​​​"tn", ​​​​​"to", ​​​​​"tog", ​​​​​"tpi", ​​​​​"tr", ​​​​​"trv", ​​​​​"ts", ​​​​​"tsi", ​​​​​"tt", ​​​​​"tum", ​​​​​"tup", ​​​​​"tut", ​​​​​"tvl", ​​​​​"tw", ​​​​​"twq", ​​​​​"ty", ​​​​​"tyv", ​​​​​"tzm", ​​​​​"udm", ​​​​​"ug", ​​​​​"uga", ​​​​​"uk", ​​​​​"umb", ​​​​​"und", ​​​​​"ur", ​​​​​"uz", ​​​​​"vai", ​​​​​"ve", ​​​​​"vi", ​​​​​"vo", ​​​​​"vot", ​​​​​"vun", ​​​​​"wa", ​​​​​"wae", ​​​​​"wak", ​​​​​"wal", ​​​​​"war", ​​​​​"was", ​​​​​"wen", ​​​​​"wo", ​​​​​"xal", ​​​​​"xh", ​​​​​"xog", ​​​​​"yao", ​​​​​"yap", ​​​​​"yav", ​​​​​"ybb", ​​​​​"yi", ​​​​​"yo", ​​​​​"ypk", ​​​​​"yue", ​​​​​"za", ​​​​​"zap", ​​​​​"zbl", ​​​​​"zen", ​​​​​"zgh", ​​​​​"zh", ​​​​​"znd", ​​​​​"zu", ​​​​​"zun", ​​​​​"zxx", ​​​​​"zza"​​​}

set commonCurrency to current application’s NSLocale’s commonISOCurrencyCodes()
–>  (NSArray) {​​​​​"AED", ​​​​​"AFN", ​​​​​"ALL", ​​​​​"AMD", ​​​​​"ANG", ​​​​​"AOA", ​​​​​"ARS", ​​​​​"AUD", ​​​​​"AWG", ​​​​​"AZN", ​​​​​"BAM", ​​​​​"BBD", ​​​​​"BDT", ​​​​​"BGN", ​​​​​"BHD", ​​​​​"BIF", ​​​​​"BMD", ​​​​​"BND", ​​​​​"BOB", ​​​​​"BRL", ​​​​​"BSD", ​​​​​"BTN", ​​​​​"BWP", ​​​​​"BYR", ​​​​​"BZD", ​​​​​"CAD", ​​​​​"CDF", ​​​​​"CHF", ​​​​​"CLP", ​​​​​"CNY", ​​​​​"COP", ​​​​​"CRC", ​​​​​"CUC", ​​​​​"CUP", ​​​​​"CVE", ​​​​​"CZK", ​​​​​"DJF", ​​​​​"DKK", ​​​​​"DOP", ​​​​​"DZD", ​​​​​"EGP", ​​​​​"ERN", ​​​​​"ETB", ​​​​​"EUR", ​​​​​"FJD", ​​​​​"FKP", ​​​​​"GBP", ​​​​​"GEL", ​​​​​"GHS", ​​​​​"GIP", ​​​​​"GMD", ​​​​​"GNF", ​​​​​"GTQ", ​​​​​"GWP", ​​​​​"GYD", ​​​​​"HKD", ​​​​​"HNL", ​​​​​"HRK", ​​​​​"HTG", ​​​​​"HUF", ​​​​​"IDR", ​​​​​"ILS", ​​​​​"INR", ​​​​​"IQD", ​​​​​"IRR", ​​​​​"ISK", ​​​​​"JMD", ​​​​​"JOD", ​​​​​"JPY", ​​​​​"KES", ​​​​​"KGS", ​​​​​"KHR", ​​​​​"KMF", ​​​​​"KPW", ​​​​​"KRW", ​​​​​"KWD", ​​​​​"KYD", ​​​​​"KZT", ​​​​​"LAK", ​​​​​"LBP", ​​​​​"LKR", ​​​​​"LRD", ​​​​​"LSL", ​​​​​"LTL", ​​​​​"LVL", ​​​​​"LYD", ​​​​​"MAD", ​​​​​"MDL", ​​​​​"MGA", ​​​​​"MKD", ​​​​​"MMK", ​​​​​"MNT", ​​​​​"MOP", ​​​​​"MRO", ​​​​​"MUR", ​​​​​"MVR", ​​​​​"MWK", ​​​​​"MXN", ​​​​​"MYR", ​​​​​"MZE", ​​​​​"MZN", ​​​​​"NAD", ​​​​​"NGN", ​​​​​"NIO", ​​​​​"NOK", ​​​​​"NPR", ​​​​​"NZD", ​​​​​"OMR", ​​​​​"PAB", ​​​​​"PEN", ​​​​​"PGK", ​​​​​"PHP", ​​​​​"PKR", ​​​​​"PLN", ​​​​​"PYG", ​​​​​"QAR", ​​​​​"RON", ​​​​​"RSD", ​​​​​"RUB", ​​​​​"RWF", ​​​​​"SAR", ​​​​​"SBD", ​​​​​"SCR", ​​​​​"SDG", ​​​​​"SEK", ​​​​​"SGD", ​​​​​"SHP", ​​​​​"SKK", ​​​​​"SLL", ​​​​​"SOS", ​​​​​"SRD", ​​​​​"SSP", ​​​​​"STD", ​​​​​"SVC", ​​​​​"SYP", ​​​​​"SZL", ​​​​​"THB", ​​​​​"TJS", ​​​​​"TMT", ​​​​​"TND", ​​​​​"TOP", ​​​​​"TRY", ​​​​​"TTD", ​​​​​"TWD", ​​​​​"TZS", ​​​​​"UAH", ​​​​​"UGX", ​​​​​"USD", ​​​​​"UYU", ​​​​​"UZS", ​​​​​"VEF", ​​​​​"VND", ​​​​​"VUV", ​​​​​"WST", ​​​​​"XAF", ​​​​​"XCD", ​​​​​"XOF", ​​​​​"XPF", ​​​​​"YER", ​​​​​"ZAR", ​​​​​"ZMW"​​​}

set aLoc to current application’s NSLocale’s localeIdentifierFromWindowsLocaleCode:1041
–>  (NSString) "ja_JP"
— https://msdn.microsoft.com/ja-jp/library/Cc392381.aspx

set aLocID to current application’s NSLocale’s windowsLocaleCodeFromLocaleIdentifier:"ja_JP"
–>  1041

set prefLang to current application’s NSLocale’s preferredLanguages()
–>  (NSArray) {​​​​​"ja", ​​​​​"en-US", ​​​​​"en-GB", ​​​​​"fr", ​​​​​"en"​​​}

set aLangDIrect1 to current application’s NSLocale’s characterDirectionForLanguage:"ja" –日本語
–>  1 –NSLocaleLanguageDirectionLeftToRight
set aLangDIrect2 to current application’s NSLocale’s characterDirectionForLanguage:"ar" –アラビア語
–>  2 –NSLocaleLanguageDirectionRightToLeft

set aLangLineDIrect1 to current application’s NSLocale’s lineDirectionForLanguage:"ja" –日本語
–>  3 –NSLocaleLanguageDirectionTopToBottom
set aLangLineDIrect2 to current application’s NSLocale’s lineDirectionForLanguage:"ar" –アラビア語
–>  3 –NSLocaleLanguageDirectionTopToBottom

★Click Here to Open This Script 

Posted in Locale System | Tagged 10.11savvy 10.12savvy 10.13savvy | Leave a comment

Post navigation

  • Older posts
  • Newer posts

電子書籍(PDF)をオンラインストアで販売中!

Google Search

Popular posts

  • 開発機としてM2 Mac miniが来たのでガチレビュー
  • macOS 15, Sequoia
  • Pages本執筆中に、2つの書類モード切り替えに気がついた
  • Numbersで選択範囲のセルの前後の空白を削除
  • メキシカンハットの描画
  • Pixelmator Pro v3.6.4でAppleScriptからの操作時の挙動に違和感が
  • AppleScriptによる並列処理
  • Safariで「プロファイル」機能を使うとAppleScriptの処理に影響
  • macOS 15でも変化したText to Speech環境
  • AppleScript入門③AppleScriptを使った「自動化」とは?
  • デフォルトインストールされたフォント名を取得するAppleScript
  • macOS 15 リモートApple Eventsにバグ?
  • 【続報】macOS 15.5で特定ファイル名パターンのfileをaliasにcastすると100%クラッシュするバグ
  • AppleScript入門① AppleScriptってなんだろう?
  • macOS 14で変更になったOSバージョン取得APIの返り値
  • Script Debuggerの開発と販売が2025年に終了
  • NSObjectのクラス名を取得 v2.1
  • macOS 15:スクリプトエディタのAppleScript用語辞書を確認できない
  • 有害ではなくなっていたSpaces
  • AVSpeechSynthesizerで読み上げテスト

Tags

10.11savvy (1101) 10.12savvy (1242) 10.13savvy (1391) 10.14savvy (587) 10.15savvy (438) 11.0savvy (283) 12.0savvy (212) 13.0savvy (194) 14.0savvy (147) 15.0savvy (135) CotEditor (66) Finder (51) iTunes (19) Keynote (119) NSAlert (61) NSArray (51) NSBitmapImageRep (20) NSBundle (20) NSButton (34) NSColor (53) NSDictionary (28) NSFileManager (23) NSFont (21) NSImage (41) NSJSONSerialization (21) NSMutableArray (63) NSMutableDictionary (22) NSPredicate (36) NSRunningApplication (56) NSScreen (30) NSScrollView (22) NSString (119) NSURL (98) NSURLRequest (23) NSUTF8StringEncoding (30) NSView (33) NSWorkspace (20) Numbers (76) Pages (55) Safari (44) Script Editor (27) WKUserContentController (21) WKUserScript (20) WKWebView (23) WKWebViewConfiguration (22)

カテゴリー

  • 2D Bin Packing
  • 3D
  • AirDrop
  • AirPlay
  • Animation
  • AppleScript Application on Xcode
  • Beginner
  • Benchmark
  • beta
  • Bluetooth
  • Books
  • boolean
  • bounds
  • Bug
  • Calendar
  • call by reference
  • check sum
  • Clipboard
  • Cocoa-AppleScript Applet
  • Code Sign
  • Color
  • Custom Class
  • date
  • dialog
  • diff
  • drive
  • Droplet
  • exif
  • file
  • File path
  • filter
  • folder
  • Font
  • Font
  • GAME
  • geolocation
  • GUI
  • GUI Scripting
  • Hex
  • History
  • How To
  • iCloud
  • Icon
  • Image
  • Input Method
  • Internet
  • iOS App
  • JavaScript
  • JSON
  • JXA
  • Keychain
  • Keychain
  • Language
  • Library
  • list
  • Locale
  • Localize
  • Machine Learning
  • Map
  • Markdown
  • Menu
  • Metadata
  • MIDI
  • MIME
  • Natural Language Processing
  • Network
  • news
  • Noification
  • Notarization
  • Number
  • Object control
  • OCR
  • OSA
  • parallel processing
  • PDF
  • Peripheral
  • process
  • PRODUCTS
  • QR Code
  • Raw AppleEvent Code
  • Record
  • rectangle
  • recursive call
  • regexp
  • Release
  • Remote Control
  • Require Control-Command-R to run
  • REST API
  • Review
  • RTF
  • Sandbox
  • Screen Saver
  • Script Libraries
  • sdef
  • search
  • Security
  • selection
  • shell script
  • Shortcuts Workflow
  • Sort
  • Sound
  • Spellchecker
  • Spotlight
  • SVG
  • System
  • Tag
  • Telephony
  • Text
  • Text to Speech
  • timezone
  • Tools
  • Update
  • URL
  • UTI
  • Web Contents Control
  • WiFi
  • XML
  • XML-RPC
  • イベント(Event)
  • 未分類

アーカイブ

  • 2025年6月
  • 2025年5月
  • 2025年4月
  • 2025年3月
  • 2025年2月
  • 2025年1月
  • 2024年12月
  • 2024年11月
  • 2024年10月
  • 2024年9月
  • 2024年8月
  • 2024年7月
  • 2024年6月
  • 2024年5月
  • 2024年4月
  • 2024年3月
  • 2024年2月
  • 2024年1月
  • 2023年12月
  • 2023年11月
  • 2023年10月
  • 2023年9月
  • 2023年8月
  • 2023年7月
  • 2023年6月
  • 2023年5月
  • 2023年4月
  • 2023年3月
  • 2023年2月
  • 2023年1月
  • 2022年12月
  • 2022年11月
  • 2022年10月
  • 2022年9月
  • 2022年8月
  • 2022年7月
  • 2022年6月
  • 2022年5月
  • 2022年4月
  • 2022年3月
  • 2022年2月
  • 2022年1月
  • 2021年12月
  • 2021年11月
  • 2021年10月
  • 2021年9月
  • 2021年8月
  • 2021年7月
  • 2021年6月
  • 2021年5月
  • 2021年4月
  • 2021年3月
  • 2021年2月
  • 2021年1月
  • 2020年12月
  • 2020年11月
  • 2020年10月
  • 2020年9月
  • 2020年8月
  • 2020年7月
  • 2020年6月
  • 2020年5月
  • 2020年4月
  • 2020年3月
  • 2020年2月
  • 2020年1月
  • 2019年12月
  • 2019年11月
  • 2019年10月
  • 2019年9月
  • 2019年8月
  • 2019年7月
  • 2019年6月
  • 2019年5月
  • 2019年4月
  • 2019年3月
  • 2019年2月
  • 2019年1月
  • 2018年12月
  • 2018年11月
  • 2018年10月
  • 2018年9月
  • 2018年8月
  • 2018年7月
  • 2018年6月
  • 2018年5月
  • 2018年4月
  • 2018年3月
  • 2018年2月

https://piyomarusoft.booth.pm/items/301502

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org

Forum Posts

  • 人気のトピック
  • 返信がないトピック

メタ情報

  • ログイン
  • 投稿フィード
  • コメントフィード
  • WordPress.org
Proudly powered by WordPress
Theme: Flint by Star Verte LLC