且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

我删除了Xcode中的本地化,然后我无法添加任何本地化

更新时间:2023-02-09 09:52:27

添加本地化



删除本地化时有时你可以得到你无法在Xcode中添加任何本地化的情况。转到命令行并创建一个 ISO 639-1双字母语言缩写文件夹,其中包含lproj扩展名在你的项目中。

Adding back a localization

When you delete your localizations sometimes you can get that situation where you can't add back any localizations in Xcode. Go to the command-line and create a ISO 639-1 two-letter language abbreviation folder with the lproj extension somewhere within your project.

例如:

${SRCROOT}/Resources/Translations/nb.lproj

${SRCROOT}/Resources/Translations/en.lproj



将语言文件重新添加到项目中



在文件夹中创建一个名为 Localizable.strings 的空文件,并将此文件添加到您的项目中。不要添加 .lproj 文件夹,只添加内容。然后,当您返回项目文件时,您将看到本地化下的语言。现在,当您添加此项时,您应该在项目中看到本地化。

Re-add language files to project

In the folder create an empty file called Localizable.strings and add this file to your project. Don't add the .lproj folder, just the contents. Then when you go back into the project file you will see the language under localizations. Now when you have added this, you should see the localization in your project.

如果添加的文件(如故事板)旁边没有复选框表明这是语言本地化的一部分,您可能需要通过另一种语言来转发它们。为此,请在项目中添加新语言。它应该提示您将现有的本地化文件复制到新语言。然后删除损坏的本地化并重新添加。

If the added file, like a storyboard, doesn't have a checkbox next to it indicating that is part of that language localization you might need to round trip them through another language. To do this add a new language in the project. It should prompt you to copy the existing localized files over to the new language. Then delete the broken localization and re-add it.

作为一个具体示例,我将nb.lproj目录中的storyboard添加到项目中。挪威语Bokmål出现在项目中,但故事板检查器中语言的复选框不允许我添加它。我在项目中创建了nb_NO,它促使我复制了故事板。然后故事板检查了该复选框。我删除了'nb'本地化并重新添加了它。现在一切都是我想要的方式。

As a specific example, I added the storyboard in the nb.lproj directory to the project. The Norwegian Bokmål appears in the project, but the checkbox for the language in the storyboard inspector won't let me add it. I created nb_NO in the project and it prompted me to copy over the storyboard. Then the storyboard had that checkbox checked. I deleted the 'nb' localization and re-added it. Now everything was the way I wanted it.