10

I searched for this error online and here. Online it shows me results in a different language then english nice Google. Here it has one post and a guy that never really answered the guys question.

I have my xcode project folder on my desktop. Inside the project folder I have an en.lproj folder that has both iPad and iPhone storyboards inside along with a localization.plist file. However when I launch the project in Xcode this en.lproj folder is nowhere to be found. So this might be the problem?

With the project folder on my desktop I launch terminal type in: cd

then drag my project folder into Terminal and it gives me the path. I then paste this line of code into the Terminal

find . -name *.m | xargs genstrings -o en.lproj

I get this error message in the Terminal:

genstrings: couldn't connect to output directory en.lproj

it prints this line multiple times and then says my project is a path to a directory?

No .strings file is made. Any thoughts on what I am doing wrong? I got UILabels that I dragged and dropped from inside Storyboards, but I also I strings that are coded with

NSLocalizedString(@"First Level Passed", @"This is a message displayed on screen to allow the user to know they have passed the first level!");

So the above Terminal code snippet should be finding those NSLocalizedStrings right? I think it isn't even getting to find the en.lproj folder in the first place but I don't know?

Any help would be great.

4

3 回答 3

17

迟到总比不好,

您正在文件夹 projectroot/en.lproj 中创建一个文件 (localizable.strings)。如果此文件夹不存在,您会收到此错误消息。只需在根目录中创建文件夹 en.lproj,该命令就可以工作。

于 2013-03-27T13:25:27.407 回答
5

我得到了同样的错误,同时按照教程执行以下命令。

genstrings -o en.lproj *.swift

上面的命令给了我以下错误:

genstrings:无法连接到输出目录 en.lproj

我的问题:

  • 我尝试在我自己的目录(即根项目目录的子目录)上实现上述命令,其中所有“.lproj”目录都在那里。- 这给了我以上错误。
  • 然后我在子文件夹“Localization”中删除了旧的“Localizable.strings”。并在根目录中创建了新的“Localizable.strings”。- 这里我没有错误,但按照“genstrings”命令没有发生任何事情。

解决方案:

在命令行移动到项目的根目录,您可以获得所有“.lproj”目录。

添加文件路径,其中列出了所有“NSLocalizedString(“TEXT”,评论:“COMMENT”)” - 在我的情况下,我已经列出了“Constants.swift”文件中的所有内容。

所以,我已经执行了以下命令,它的工作就像魅力一样。

 genstrings -o en.lproj/ #ProjectPath#/Constants/Constants.swift

注意:只需将文件从 Xcode 拖放到终端即可轻松获取文件路径。

于 2019-06-29T08:14:46.627 回答
0

解决方案是手动创建文件夹 en.lproj,然后运行 ​​genstring 命令

cd {project folder}
mkdir Localization
cd Localization
mkdir en.lproj
genstrings -o en.lproj/ ../*.swift

为法语等的每种语言重复(即:fr.lproj)。

于 2021-05-15T08:53:13.780 回答