Xcode 6.3.2或6.4beta本地化无法读取字符串文件 [英] Xcode 6.3.2 or 6.4beta Localization failed to read a strings file

查看:247
本文介绍了Xcode 6.3.2或6.4beta本地化无法读取字符串文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是的,我知道有很多关于这次失败的讨论。但在检查之后,我认为现在的情况有所不同。



在这里,此警告消息和您可以提供的任何有用信息。



xcodebuild:错误:本地化失败读取字符串文件


即使我注释掉第26行,这个错误仍然存​​在,这是

  var str = NSLocalizedString(Hi,tableName:nil,bundle:NSBundle.mainBundle(),value:评论:嗨)

但如果删除第26行,则错误消失。



所以,我猜,XLIFF发生器不知何故不允许NSLocalizedString出现?



你有没有像我一样发现这个? / p>

解决方案

我在Xcode 8.1上遇到与Swift 3相同的问题,因为我有一个扩展名

  func localized() - >字符串{
返回NSLocalizedString(self,comment:self)
}

I修复它删除扩展名并直接使用NSLocalizedString(,comment:)。当我尝试导出.xliff文件时,我真的不知道为什么扩展名不起作用。


Yes, I know there are many discussions about this failure. But after checking them out, I think what I have now is different.

In here Error while "Export For Localization.." Xcode 6.3, it says the single quote (') should be replaced as (\') in the strings file.

In here Xcode 6 localization failed to read a strings file, it says that the NSLocalizedString should be commented out (if I understand it right).

To test the problem, I created a new project with 6.3.2 and 6.4(6E23). I can have single quotes in the strings file, but as long as there is NSLocalizedString (e.g. var str = NSLocalizedString("Hi", tableName: nil, bundle: NSBundle.mainBundle(), value: "Hi", comment: "Hi")) in the view controller file, the Xcode always pops up with

Then I did

xcodebuild -exportLocalizations -localizationPath ./xliff -project testtest.xcodeproj -exportLanguage en

and I get

Bad entry in file ViewController.swift (line = 26): Argument is not a literal string.

2015-06-15 11:08:22.177 xcodebuild[31272:1150546]

[MT] DVTAssertions: Warning in /SourceCache/IDEFrameworks/IDEFrameworks-7718/IDEFoundation/Localization/IDELocalizationWork.m:434

Details: Failed to read strings file "/var/folders/1s/_d08hx4j2gn9t6wlrc5_7gq00000gn/T/Xcode3SourceStringsAdaptor-48CAE246-EBA5-4326-B3C5-B5032A4027D8/Localizable.strings", underlying error:

The data couldn’t be read because it isn’t in the correct format.

Object: IDELocalizationWork

Method: +readStringsWorkForContext:

Thread: {number = 1, name = main} Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.

xcodebuild: error: Localization failed to read a strings file

This error persists even if I comment out Line 26, which is

var str = NSLocalizedString("Hi", tableName: nil, bundle: NSBundle.mainBundle(), value: "Hi", comment: "Hi")

But if I delete Line 26, the error is gone.

So, I guese, the XLIFF generator somehow does not allow "NSLocalizedString" to appear whatsoever??

Have you ever found this like I did?

解决方案

I've the same problem with Swift 3 on Xcode 8.1 because I had an extension

func  localized() -> String {
    return NSLocalizedString(self, comment: self)
} 

I fixed it removing the extension and using directly NSLocalizedString("", comment: ""). I really don't know why the extension didn't work when I try to export the .xliff file.

这篇关于Xcode 6.3.2或6.4beta本地化无法读取字符串文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆