如何在 xcode4 中本地化 Settings.bundle?
我正在开发 xcode4 并为我的项目创建了一个 Settings.bundle
。我可以在 xcode4 中编辑 Root.plist
文件,但无法编辑 Root.strings
文件。它甚至没有显示在编辑器中。
我无法展开 en.lproj
文件夹,如图所示。
但是,当我右键单击,在外部编辑器中打开时,它会显示:
双击 Root.strings
会显示:
我尝试了几次,创建了一个新的基于窗口的应用程序项目并创建了一个新的Settings.bundle。我总是无法本地化它。有什么想法吗?
I am working on xcode4 and created a Settings.bundle
for my project. I can edit the Root.plist
file in xcode4 but it is not possible to edit the Root.strings
file. It isn't even displayed in the editor.
I can not expand the en.lproj
folder as you see in the picture.
But when I do right-click, open in external editor it gives me:
Double click on Root.strings
gives me:
I tried it several times, creating a new window-based application project and creating a new Settings.bundle. I always can not localize it. Any ideas?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(6)
在 XCode 4.2 中,您必须遵循以下步骤(只需修改 Xcode 3.2.2 和 Settings.bundle 本地化)
In XCode 4.2 you have to follow this steps (just a modification of Xcode 3.2.2 and localization of Settings.bundle)
编辑:苹果再次修复了错误的错误。他们的改变使我的解决方法变得毫无用处。它不再起作用了,您无法将文件添加到 Settings.bundle 中。
请参考Javi的答案,寻找似乎有效的方法。
希望你喜欢丑陋的解决方法。
新建文件
我希望这对你有用,对我也有用。
如果您还没有这样做,请在 bugreport.apple.com 报告错误,
我将安装现在新版本发布了,看看这个问题是否修复了。编辑:未修复。
编辑:我不知道我是否正确理解你的第二个问题。但是,当您将本地化添加到捆绑包外部出现的文件时,它会将本地化文件夹添加到 settings.bundle
将西班牙语本地化添加到
Root.strings
后:实际文件位于 foo.lproj 文件夹中,只是不在 xcode 侧边栏中显示它们。如果您检查文件系统中的位置,您将看到它们位于设置包内。
昨天我检查了英语和德语文件,它在模拟器中工作正常。我想这只是一个错误的侧边栏布局。文件的底层位置和处理似乎是正确的。
EDIT: Apple fixed, once again, the wrong bug. Their change rendered my workaround useless. It just doesn't work anymore, you can't add files to the Settings.bundle.
Please refer to the answer of Javi for a method that seems to work.
I hope you like ugly workarounds.
New File
I hope this works for you, for me it does.
And if you haven't done it please report the bug at bugreport.apple.com
I'll install the new release now, let's see if this is fixed. Edit: Not fixed.
EDIT: I don't know If I understood your second question correctly. But when you add a localization to the file that appears outside of the bundle it adds a localization folder to the settings.bundle
After adding spanish localization to
Root.strings
:The actual file is in the foo.lproj folder, it just doesn't show them in the xcode sidebar. If you check the location in the file system you'll see they are inside the settings bundle.
Yesterday I checked with a english and german file and it worked correctly in the simulator. I guess it's just a wrong sidebar layout. The underlying locations and the handling of the files seems correct.
对我来说,它可以将文件夹“en.lproj”的文件类型(在文件检查器中)从“默认/目录”更改为“目录”。魔法。
For me it worked to change the File Type (in the File Inspector) of the Folder "en.lproj" from "Default / Directory" to "Directory". Magic.
Xcode 4 正在创建“Root.strings”作为二进制属性列表。所以我必须做的是将文件类型设置为“属性列表(二进制)”才能正确显示。
Xcode 4 is creating the "Root.strings" as a binary property list. so what I had to do was set the file type to "Property List (binary)" for it to show up correctly.
我刚刚放弃尝试用 Root.strings 做一些事情。相反,我只是将 plist 复制到每个 *.lproj 中,并且它起作用了!
就翻译成英语和我的母语而言,没问题。
所以我有:
好消息是 Root.plist 是 utf8。
I have just given up trying to do something with Root.strings. Instead, I just copied the plist into each *.lproj, and it worked!
As far as this is about translation into English and my native language, no problem.
So I have:
The good news is that Root.plist is utf8.
如果您已经有一个“属性列表(二进制)”的 Root.strings 文件,并且希望将其转换为正确的基于文本的字符串文件,则可以在终端应用程序中使用
plutil
来将其转换为 JSON 格式:注意,您可以运行 plutil -h 来获取使用帮助。
但是,您随后需要将 JSON 格式转换
为字符串文件的格式:
这可以通过在文本编辑器中进行一些搜索/替换操作轻松完成。
If you already have a Root.strings file that is a "Property List (binary)" and you wish to convert it to a proper text-based strings file, you can use
plutil
in the Terminal application to convert it, for instance into JSON format:N.B. You can run
plutil -h
for usage help.However, you will then need to convert the JSON format:
to that of a strings file:
This is easily done with a few search/replace operations in a text editor.