ICL1901
ICL1901

Reputation: 7778

How to use xCode core data localization strings

I'm localizing a Core Data -based app. I've localized all of the strings, and now just have the core data properties to work on.

I've looked at several posts here on SO, and am reading Apple's docs on Core Data localization, but I'm stuck.

I have created string file like so:

"Entity/AppEntity" = "App";
"Entity/PeopleEntity" = "People";
"Property/name" = "Name";
"Property/lastName" = "Last Name";
"Property/address1/Entity/PeopleEntity" = "Address Line 1";

I have named these files appModel.strings, and placed them in each .lproj directory.

But they are not being used.

I have sub-classed each entity.

Do I need to specifically invoke these localization strings? If so, I'd really appreciate an example.. I could not find an Apple sample, but if there is one, that would be brilliant.

Many thanks..

Upvotes: 0

Views: 869

Answers (2)

Kelvin Chan
Kelvin Chan

Reputation: 23

The localized string should be put under a file called 'Localizable.strings' kept under your XCode project. I think you already know how to generate it using 'genstrings'.

Now import the file into your project, with the file Localizable.strings selected. Go to 'File Inspector' (on the right side). You will find a section called 'Localization'. click the '+' sign and select the language you want to localize. If your project is based on 'en', then there will be a subdirectory called en.lproj created and your Localizable.strings put under it. Keep adding localized version will create additional directory and a copy of the original one.

Next is to update the content of 'Localized' version. In iPhone simulator, change the 'International' settings for different countries, you will find your localized version text displayed.

Of course, it applies to those use NSLocalizedString.

Upvotes: 1

Mundi
Mundi

Reputation: 80271

Yes. I believe you have to use this every time you use a localized string:

 NSLocalizedString(entity.stringAttribute, @"commentOrNil")

Upvotes: 1

Related Questions