我刚刚将我的Mac OS更新为Mavericks,并在我的项目中遇到了问题。
我在使用Apple脚本的plist中更新本地化密钥。但是当我设置本地化密钥时plist文件变为0 KB。
它适用于Mac OS 10.8。
下面是我更改plist键的脚本:
if keyVar as string = "CFBundleLocalizations" then
-- Parse the string for delimiter , and get the array of schemes
set AppleScript's text item delimiters to ","
set theLanguageItems to text items of valVar
-- restore delimiters to previous.if not reset then creats error for below code if we have any property below CFBundleLocalizations propert file.
set AppleScript's text item delimiters to "="
--if there are localization available
if the length of theLanguageItems is greater than 0 then
--create structure for CFBundleLocalizations
tell application "System Events"
set pFile to property list file plistFile
tell pFile
tell contents
--and write to the plist file
--make new property list item with properties {kind:list, value:"theLanguageItems"}
set value of property list item "CFBundleLocalizations" to theLanguageItems
end tell
end tell
end tell
end if
答案 0 :(得分:1)
在小牛队中,似乎AppleScript的行为不同,set value of property list item
无法正常工作。
另一种方法是使用您评论过的make new property
。在这种情况下,将创建一个新属性并将其附加到现有属性。因此,你需要小心。
以下是适用于数组列表的实际解决方案
repeat with theCurrentValue in theLanguageItems
make new property list item with properties {kind:string, value:theCurrentValue}
end repeat