如果您正在Settings.bundle中构建子窗格,则会得到多个.plist文件。在本地化项目时,创建相应的.strings文件可能会让您感到有点繁琐(我知道我是这样的)。
下面是一个方便的bash脚本列表,它将(i)查找标签,(ii)提取以下标签的内容,然后(iii)将该值输出到文本文件中,“string”=“string”格式需要ibtool。
您可以将输入和输出文件名作为参数传递。
下面是一个方便的bash脚本列表,它将(i)查找标签,(ii)提取以下标签的内容,然后(iii)将该值输出到文本文件中,“string”=“string”格式需要ibtool。
您可以将输入和输出文件名作为参数传递。
#!/bin/sh
echo "// Generated by plist2strings. Manual edits will be overwritten the next time this script runs.\n/* A single strings file, whose title is specified in your preferences schema. The strings files provide the localized content to display to the user for each of your preferences. */\n" > plist2stringstmp
sed -n '
# look for a "#" at the end of the line
/<key>Title<\/key>$/ {
# Found one - now read in the next line
N
# delete the "#" and the new line character,
s/.*<\(string\)>\(.*\)<\/\1>/"\2" = "\2"/gp
}' $1 > plist2stringstmp2
cat plist2stringstmp plist2stringstmp2 > $2
rm plist2stringstmp plist2stringstmp2
将文本复制并粘贴到一个文本文件中。我把我的保存为plist2strings。确保赋予它执行权限。例如,在终端执行:
macbook:~ foo$ chmod 755 plist2strings
如果脚本保存在您的用户文件夹中,要从Settings.bundle目录的根目录执行脚本,只需使用以下语法:
macbook:~ foo$ ~/plist2strings mysettings.plist en.lprog/mysettings.strings
如果 mysettings.strings 在该文件夹中不存在,它将被创建。 如果它已经存在,它会自动覆盖而无需警告。
希望有人觉得这个有用。 随意使用和滥用,但需注意(买家自负)。 如果您做出任何有用的更改,请考虑将它们发布在此处供其他人享受。
祝本地化愉快!
〜Zack