使用附加字符串本地化Info.plist变量 [英] Localizing Info.plist variable with appended string
问题描述
我正在尝试本地化应用程序的名称,同时仍然能够根据构建配置附加字符串.因此,目前将其设置为:
I'm trying to localize the name of an app while still being able to append a string depending on the build configuration. So currently it is set up as:
<key>CFBundleDisplayName</key>
<string>${PRODUCT_NAME}${BUNDLE_DISPLAY_NAME_SUFFIX}</string>
该设置定义为:
通过这种方式,我们可以将后缀添加到应用程序中,以用于不同的beta版本.问题是,当我们尝试像这样在本地化的InfoPlist.strings
中本地化应用程序显示名称时,
This way we can add the suffix to the app for our different beta builds. The problem is that when we try to localize the app display name in the localized InfoPlist.strings
like so
CFBundleDisplayName = "Localized App Name";
我们将覆盖存储在Info.plist
中的值,并丢失后缀字符.有什么好办法解决吗?我们希望避免有多个Info.plist
文件.
We overwrite the value stored in the Info.plist
, and lose the suffix character. Is there any good way around this? We would like to avoid having multiple Info.plist
files.
推荐答案
您将需要一个自定义脚本来执行此操作.这是一个为我工作的人
You will need a custom script to do this. Here is one that is working for me
PREFIX_IDENTIFIER="=com.mycompany.bundlenameprefix="
PREFIX=""
if [ $CONFIGURATION == "Debug" ]
then
PREFIX="α "
fi
if [ $CONFIGURATION == "Enterprise" ]
then
PREFIX="β "
fi
for i in `dirname "${TARGET_BUILD_DIR}/${INFOPLIST_PATH}"`/*.lproj/InfoPlist.strings
do
plutil -convert json "$i"
sed -i -e "s/${PREFIX_IDENTIFIER}/${PREFIX}/g" "$i"
plutil -convert binary1 "$i"
done
然后在您的InfoPlist.strings中像这样为捆绑包名称添加前缀
Then in your InfoPlist.strings add a prefix to the bundle name like so
CFBundleDisplayName = "=com.mycompany.bundlenameprefix=My App";
这篇关于使用附加字符串本地化Info.plist变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!