Bundle IDで指定したアプリケーションのバンドル中(/Contents/Resources/)のすべてのLocalizationに存在する指定のstringsファイル内で、指定キーの値を取得するAppleScriptです。
macOSの日本語環境では、Finder上でコピーしたファイルのファイル名の後方に「のコピー」といった文字列が追記されますが、他のLocaleでどのような文字列が使用されているか調査するために作成したものです。
AppleScript名:指定アプリケーション内の全Localeの指定stringsファイル内の指定キーの値を取得する.scptd |
— – Created by: Takaaki Naganoya – Created on: 2019/11/12 — – Copyright © 2019 Piyomaru Software, All Rights Reserved — use AppleScript version "2.5" use scripting additions use framework "Foundation" property |NSURL| : a reference to current application’s |NSURL| property NSArray : a reference to current application’s NSArray property NSBundle : a reference to current application’s NSBundle property NSPredicate : a reference to current application’s NSPredicate property NSDictionary : a reference to current application’s NSDictionary property NSWorkspace : a reference to current application’s NSWorkspace property NSFileManager : a reference to current application’s NSFileManager property NSMutableDictionary : a reference to current application’s NSMutableDictionary property NSURLTypeIdentifierKey : a reference to current application’s NSURLTypeIdentifierKey set targID to "com.apple.Finder" set targFile to "Localizable.strings" set targKey to "N4_V2" set vList to getAValInASpecifiedStringFileOfAllLocaleInABundle(targID, targFile, targKey) of me –> {{"he", "עותק של ^=1 ^=0"}, {"en_AU", "^=1 copy ^=0"}, {"ar", "نسخة ^=0 من ^=1"}, {"el", "^=1 αντίγραφο ^=0"}, {"uk", "^=1 копія ^=0"}, {"English", "^=1 copy ^=0"}, {"es_419", "Copia de ^=1 ^=0"}, {"zh_CN", "^=1的副本 ^=0"}, {"Dutch", "^=1 kopie ^=0"}, {"da", "^=1-kopi ^=0"}, {"sk", "^=1 – kópia ^=0"}, {"pt_PT", "^=1 – cópia ^=0"}, {"German", "^=1 Kopie ^=0"}, {"ms", "salinan ^=0 ^=1"}, {"sv", "^=1 (kopia ^=0)"}, {"cs", "^=1 (kopie ^=0)"}, {"ko", "^=1 복사본 ^=0"}, {"no", "^=1-kopi ^=0"}, {"hu", "^=1 másolat ^=0"}, {"zh_HK", "^=1 副本 ^=0"}, {"Spanish", "^=1 copia ^=0"}, {"tr", "^=1 kopyası ^=0"}, {"pl", "^=1-kopia ^=0"}, {"zh_TW", "^=1 拷貝 ^=0"}, {"en_GB", "^=1 copy ^=0"}, {"French", "^=1 copie ^=0"}, {"vi", "Bản sao ^=1 ^=0"}, {"ru", "^=1 — копия ^=0"}, {"fr_CA", "^=1 copie ^=0"}, {"fi", "^=1 kopio ^=0"}, {"id", "Salinan ^=1 ^=0"}, {"th", "^=1 สำเนา ^=0"}, {"pt", "^=1 – cópia ^=0"}, {"ro", "^=1 – copie ^=0"}, {"Japanese", "^=1のコピー^=0"}, {"hr", "^=1 kopija ^=0"}, {"hi", "^=1 कॉपी ^=0"}, {"Italian", "^=1 copia ^=0"}, {"ca", "^=1 còpia ^=0"}} on getAValInASpecifiedStringFileOfAllLocaleInABundle(targID, targFile, targKey) –Get App Path set aPath to retPathFromBundleID(targID) of me –Get all Localizations set bRes to getLocalizationsFromBundleID(targID) of me set hitList to {} –Loop with Localizations in an application bundle repeat with iii in bRes set jjj to contents of iii set allPath to aPath & "/Contents/Resources/" & jjj & ".lproj/" & targFile set aDict to (NSDictionary’s alloc()’s initWithContentsOfFile:allPath) if aDict is not equal to missing value then set aVal to (aDict’s valueForKeyPath:(targKey)) if aVal is not equal to missing value then set the end of hitList to {jjj, aVal as string} end if end if end repeat return hitList end getAValInASpecifiedStringFileOfAllLocaleInABundle on getLocalizationsFromBundleID(aBundleID) set aRes to retPathFromBundleID(aBundleID) of me if aRes = false then error "Wrong Bundle ID." return getSpecifiedAppFilesLocalizationListWithDuplication(aRes) of me end getLocalizationsFromBundleID –指定アプリケーションファイルの、指定Localeにおけるローカライズ言語リストを求める。重複を許容 on getSpecifiedAppFilesLocalizationListWithDuplication(appPOSIXpath) set aURL to (|NSURL|’s fileURLWithPath:appPOSIXpath) set aBundle to NSBundle’s bundleWithURL:aURL set locList to aBundle’s localizations() return locList as list end getSpecifiedAppFilesLocalizationListWithDuplication on retPathFromBundleID(aBundleID) set aURL to NSWorkspace’s sharedWorkspace()’s URLForApplicationWithBundleIdentifier:aBundleID if aURL = missing value then return false –Error return aURL’s |path|() as string end retPathFromBundleID |
More from my site
(Visited 61 times, 3 visits today)