配列に入れた言語コードに対して、指定のLocaleの言語による表現で、言語名称を求めるAppleScriptです。
AppleScript名:指定の言語コードを、指定のLocaleの表現で、言語名称に.scpt |
— – Created by: Takaaki Naganoya – Created on: 2020/08/14 — – Copyright © 2020 Piyomaru Software, All Rights Reserved — use AppleScript version "2.4" use scripting additions use framework "Foundation" set langList to {"en", "ru", "ja"} set aList to getLocalizedLangNameList(langList, "ja_JP") of me –> {"英語", "ロシア語", "日本語"} set aList to getLocalizedLangNameList(langList, "en_US") of me –> {"English", "Russian", "Japanese"} set aList to getLocalizedLangNameList(langList, "zh-Hans") of me —> {"英文", "俄文", "日文"} on getLocalizedLangNameList(langList, aLocaleID) set aLocale to (current application’s NSLocale’s localeWithLocaleIdentifier:aLocaleID) set langLocalizedList to {} repeat with i in langList set aLang to getLangNameWithLocale(i, aLocale) of me set the end of langLocalizedList to aLang end repeat return langLocalizedList end getLocalizedLangNameList on getLangNameWithLocale(langCode, aLocale) set aLangName to (aLocale’s displayNameForKey:(current application’s NSLocaleIdentifier) value:langCode) as string return aLangName end getLangNameWithLocale |
More from my site
(Visited 42 times, 1 visits today)