2

我刚刚将我的 Mac OS 更新为 Mavericks 并在我的项目中遇到了一个问题。

我使用苹果脚本在 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
4

1 回答 1

1

在 Mavericks 中,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  
于 2013-10-30T06:21:02.460 回答