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 previous file but when I want to add a new Localization, a window popped out and asked me to "Choose files and reference language to create English localization" and there is no resource file at all.
How can I add back the localizations?
Recent versions of XCode doesn't create Localizable. strings file by default. To add Localizable. strings file, go to File->New->File , choose Strings File under Resource tab of iOS, name it Localizable.
strings" and open the File Inspector (keyboard shortcut cmd-opt-1 or View > Utilities > Show File Inspector in the menu bar). You'll see a Localization pane with your localizations listed. Select the one you want to remove and click the minus sign to delete it.
Tell Xcode to put it there by selecting it in the Project navigator, then clicking Localize… in the File inspector. Xcode will ask you to confirm the file's language. The default will be English since that's your development language. Click Localize.
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.
For example:
${SRCROOT}/Resources/Translations/nb.lproj
or
${SRCROOT}/Resources/Translations/en.lproj
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With