I deleted the Localizations in Xcode, then I cannot add any Localizations back

后端 未结 6 1563
陌清茗
陌清茗 2021-01-30 13:54

I deleted the Localizations of the project from the project\'s info by mistake. Both the storyboard and the related language were removed.

I got back the storyboard from

6条回答
  •  自闭症患者
    2021-01-30 14:39

    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.

    Create an empty language folder

    For example:

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

    or

    ${SRCROOT}/Resources/Translations/en.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.

    No checkbox

    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.

    My Example

    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.

提交回复
热议问题