Xcode 本地化快把我逼疯了!未加载故事板
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12782599/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Xcode Localization is driving me nuts! Not loading Storyboard
提问by Stéphane Schorderet
It's been 2 days this issue is driving me nuts.
已经 2 天了,这个问题让我发疯了。
I'm trying to localize my iOS app but for the life of me I can't get it to work. It works easy enough when I try on a blank project but not on my current project.
我正在尝试本地化我的 iOS 应用程序,但在我的生活中我无法让它工作。当我尝试一个空白项目而不是我当前的项目时,它很容易工作。
I've added the languages in the Localizations using "+", I've localized the storyboard but when I check on simulator or device I still see the english version. And in fact it's not even the English one because if I change the Maintsoryboard (english) I don't see the changes in the device ... I still see the initial texts.
我已经使用“+”在本地化中添加了语言,我已经本地化了情节提要,但是当我检查模拟器或设备时,我仍然看到英文版本。事实上,它甚至不是英文的,因为如果我更改 Maintsoryboard(英文),我看不到设备的变化......我仍然看到初始文本。
I've tried reseting the simulator, deleted the app, etc. No luck.
我试过重置模拟器,删除应用程序等。不走运。
I've reverted to a backup tried adding everything again. No luck.
我已经恢复到备份尝试再次添加所有内容。没运气。
Can someone please help? I know it's not much to go on, but I don't know what to explain to help you help me. So please let me know if I'm missing some info.
有人可以帮忙吗?我知道这没什么好说的,但我不知道要解释什么来帮助你帮助我。所以如果我遗漏了一些信息,请告诉我。
FYI, when I look into the app's folder in Developer, I initially don't have a en.lproj when it seems I should have one by default?
仅供参考,当我在 Developer 中查看应用程序的文件夹时,我最初没有 en.lproj,但似乎默认情况下应该有一个?
回答by Jon Hess
It looks like you already figured this out, but I think what probably happened is that originally you had "MainStoryboard.storyboard" as an unlocalized resource. This means that when you build your app, you get a "MainStoryboard.storyboardc" as an unlocalized resource. When you change your storyboard to be localized, you get a "Base.lproj/MainStoryboard.storyboardc" in your bundle resources.
看起来您已经明白了这一点,但我认为可能发生的情况是最初您将“MainStoryboard.storyboard”作为未本地化的资源。这意味着当你构建你的应用程序时,你会得到一个“MainStoryboard.storyboardc”作为未本地化的资源。当您将故事板更改为本地化时,您的包资源中会出现“Base.lproj/MainStoryboard.storyboardc”。
There are several copies of your app when you're building in Xcode. There's the copy on your device or in the simulator, and there's also a copy in your derived data folder in Xcode. When you do an incremental build of your application, the copy in the derived data folder in Xcode is a merge of your new content and your old content. So, when you modify a resource in Xcode, and rebuild, you get the newest resource. However when you rename or delete resources, the old copy is still left in the build directory until you perform a clean operation.
当您在 Xcode 中构建时,您的应用程序有多个副本。在您的设备或模拟器上有副本,在 Xcode 的派生数据文件夹中也有副本。当您对应用程序进行增量构建时,Xcode 中派生数据文件夹中的副本是新内容和旧内容的合并。因此,当您在 Xcode 中修改资源并重新构建时,您将获得最新的资源。但是,当您重命名或删除资源时,旧副本仍会保留在构建目录中,直到您执行清理操作。
This means that your build product probably had both "MainStoryboard.storyboardc" and "Base.lproj/MainStoryboard.storyboardc". When NSBundle loads resources, it prefers unlocalized content, and would load the old "MainStoryboard.storyboardc".
这意味着您的构建产品可能同时具有“MainStoryboard.storyboardc”和“Base.lproj/MainStoryboard.storyboardc”。当 NSBundle 加载资源时,它更喜欢未本地化的内容,并且会加载旧的“MainStoryboard.storyboardc”。
回答by Farshid
Be absolutely sure you don't have typos in Main.strings file, e.g. double quotes and semicolons. If you have any typos, device simply ignores localized strings and applies base internationalization.
绝对确保 Main.strings 文件中没有拼写错误,例如双引号和分号。如果您有任何拼写错误,设备只会忽略本地化的字符串并应用基本国际化。
回答by pkamb
Try selecting all of the various .strings
, .xib
, and .storyboard
files that are being localized.
尝试选择正在本地化的所有各种.strings
、.xib
和.storyboard
文件。
In the File Inspector, make sure that all of the needed localizations are checked for each file.
在文件检查器中,确保为每个文件检查所有需要的本地化。
After adding localization, English
was unchecked on several files. Some views were thus localizing into unintended languages. Checking English
fixed the problem.
添加本地化后,English
未选中多个文件。因此,一些观点被本地化为非预期的语言。检查English
解决了问题。
回答by djromero
Blind shot: check that the strings file is UTF-16 (little endian if I remember correctly) and it doesn't have syntax errors (missing ; or quote). Also run a project cleanbefore building after changes in strings files.
盲注:检查字符串文件是否为 UTF-16(如果我没记错的话是小端)并且它没有语法错误(缺少 ; 或引号)。在更改字符串文件后构建之前,还要运行一个干净的项目。
回答by AyAz
What I faced is only typo error like
"zu0-GQ-ymP.text" = "Meeting End Time;
just make sure and check each strings in Main.strings must be like below
只需确保并检查 Main.strings 中的每个字符串必须如下所示
"zu0-GQ-ymP.text" = "Meeting End Time";
Hint : if it is typo error it will not work in particular localization.
提示:如果是拼写错误,它将不适用于特定的本地化。