Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 924
Stella Avatar asked Sep 27 '12 14:09

Stella


People also ask

How do I create a localizable string in Xcode?

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.

How do I delete localization?

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.

How do I localize Xcode?

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.


1 Answers

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.

like image 122
Cameron Lowell Palmer Avatar answered Oct 04 '22 08:10

Cameron Lowell Palmer