Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to change text encoding of Localizable.strings file in Xcode 4?

I am learning how to localize the strings in my project and I am using Xcode 4.

I have generated the base Localizable.strings file, and I want to import this file, changing its encoding from utf-16 to Unicode utf-16 so that the text in the file is readable within xCode. If I strate import this file, when I select it within xcode, the text shows up as gibberish.

In Xcode 3 when you drag the Localizable.strings into your project, the dialog box which appears gives you the option to change the text encoding, but this is not the case in Xcode 4.

Does anyone know a way around this?

like image 261
Sabobin Avatar asked Aug 16 '11 14:08

Sabobin


1 Answers

Maybe this can help you Objective C/Xcode 4: Encoding Problem with Localizable.strings files

These kind of errors can happen if you copy and paste content within Xcode or from external files in your localization files. The consequence is that the encoding of the file changes to for example Western (Mac OS Roman). The Localizable.strings file should be in UTF-16 though.

Solution

1. Like in the picture below, navigate in Xcode to the Localizable.strings location and open it so that you can see all the languages you are supporting.

Localizable.strings

  1. Left-click on the language file the causes the build error.

  2. Make sure your Utilities View is showing in Xcode. Activate on the button at mark 1 in Picture below.

XCode Utilities

  1. In the Utilities View select the File Inspector. (Small Logo that looks like Page)

  2. Under Text Settings change the encoding to UTF-16(Marked as 2 in the picture above). The Drop-Down might be grayed out but you can click on it anyways. Click on "Convert" on the Popup.

That's it your project should now compile again.

like image 67
Edmar Miyake Avatar answered Sep 28 '22 04:09

Edmar Miyake