xcode 5 本地化失败
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/19355708/
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 5 localization failed
提问by Alex75
I have a curious problem ...
我有一个奇怪的问题......
I created a new project with xcode 5 , I deleted storyboards , since i'm working with xibs , and I removed the base localization because , from what I've read, it's useless with the xibs . I also eliminated the English localization and added the Italian one , which is what interests me.
我用 xcode 5 创建了一个新项目,我删除了故事板,因为我正在使用 xibs ,我删除了基本本地化,因为从我读过的内容来看,它对 xibs 毫无用处。我还取消了英语本地化并添加了意大利语本地化,这正是我感兴趣的地方。
I started working with the device (which is set in Italian ) and everything works properly.
我开始使用该设备(设置为意大利语)并且一切正常。
This morning , having forgotten the cable at home, I decided to use the simulator (which is set in English) and the app crashed . After some tests I realized that the problem stems from the language settings , in fact if I set the language of the simulator in Italian , everything works properly. Analyzing the situation better , I realized that some variables set in the file " Localizable.strings " and crucial for the application are not read correctly ( it sets the key and not the value ) and for this reason the app crashes .
今天早上,由于忘记了家里的电缆,我决定使用模拟器(英语设置)并且应用程序崩溃了。经过一些测试,我意识到问题出在语言设置上,实际上如果我将模拟器的语言设置为意大利语,则一切正常。更好地分析情况后,我意识到在“Localizable.strings”文件中设置的一些变量对应用程序至关重要(它设置了键而不是值),因此应用程序崩溃。
I'm pretty confident i can solve the problem by simply creating a new project and copying in the code, but I would like to know if it is possible to recover the original.
我非常有信心通过简单地创建一个新项目并复制代码来解决问题,但我想知道是否可以恢复原始项目。
Any help will be appreciated thanks
任何帮助将不胜感激谢谢
EDIT:
编辑:
1st Try:Checked the button base localization in project/info is opening an empty popup window (no files to localize)
第一次尝试:检查项目/信息中的按钮基础本地化正在打开一个空的弹出窗口(没有要本地化的文件)
2nd Try:In project/info, under localization press "+" to add base localization (i have only italian now) seems nothing changed ... it still open an empty window
第二次尝试:在项目/信息中,在本地化下按“+”添加基本本地化(我现在只有意大利语)似乎没有任何改变......它仍然打开一个空窗口
Follow some screenshots
按照一些截图
As u can see there is 1 file localized, wich is the Localizable.strings, and the check button "Use base Internationalization" unchecked.
如您所见,有 1 个文件已本地化,即 Localizable.strings,并且未选中“使用基础国际化”复选框。
Here u can see what happen either when i check "Use base Internationalization" or i add the Base language by pressing the "+" button under "Localizations".
在这里,您可以看到当我选中“使用基本国际化”或通过按“本地化”下的“+”按钮添加基本语言时会发生什么。
EDIT 2:
编辑2:
Tryed same things with iOS Deployment Target 7.0 instead of 4.3. Same Result
用 iOS 部署目标 7.0 而不是 4.3 尝试了同样的事情。结果相同
采纳答案by Alex75
Resolved. The problem arose from the fact that I had installed on the simulator an old version of Localizable.strings file as indicated in the post here.
解决。这个问题源于这样的事实出现,我已经在模拟器上安装了旧版本Localizable.strings文件作为在后表示这里。
The strange thing is that I was pretty sure I deleted and restarted the app more times before I read that post, as it is a practice that I adopt often well aware of the behavior described in the post.
奇怪的是,在我阅读那篇文章之前,我很确定我多次删除并重新启动了该应用程序,因为我经常采用这种做法,并很清楚该文章中描述的行为。
Edit:There was no need, as I thought, add the Base Localization
编辑:正如我所想的那样,没有必要添加基本本地化
回答by user3301325
Your problem is likely that the MainMenu.xib needs to be registered as a localizable resource.
您的问题很可能是 MainMenu.xib 需要注册为可本地化的资源。
- Select MainMenu.xib in the Project Navigator (left sidebar)
- If a Localize... button appears in the File Inspector (right sidebar), press it.
- Tick the Use Base Internationalization checkbox. This time MainMenu.xib should appear.
- 在项目导航器(左侧栏)中选择 MainMenu.xib
- 如果“本地化...”按钮出现在文件检查器(右侧栏)中,请按下它。
- 勾选使用基础国际化复选框。这次应该出现 MainMenu.xib。
Now when you tick additional languages for MainMenu.xib in the File Inspector, Xcode will create a MainMenu.strings file for that language. Click the disclosure triangle on MainMenu.xib in the Project Navigator to edit it.
现在,当您在文件检查器中为 MainMenu.xib 勾选其他语言时,Xcode 将为该语言创建一个 MainMenu.strings 文件。单击 Project Navigator 中 MainMenu.xib 上的显示三角形以对其进行编辑。
回答by Peter Segerblom
When working with Localization you need a base language, one that can be used if the language the device wants to use is not present. If no file can be found it will use the key. One trick, since keys can be a sentence, is to let your key be the your base language.
使用 Localization 时,您需要一种基本语言,如果设备要使用的语言不存在,则可以使用这种语言。如果找不到文件,它将使用密钥。一个技巧,因为键可以是一个句子,就是让你的键成为你的基本语言。