I want to localize a Fruits entity a name and type attributes. The static data is initially stored in a NSArray, and then loaded into core data. Here is an example of the static data: Apple, Pear, Grapes, Kiwi, etc., and they are stored inside of the Fruits entity. Unfortunately, when using NSLocalizedStringFromFile on the static array, and then setup
en.strings file:
"Property/Apple" = "Apple";
"Property/Pear" = "Pear";
es.strings file:
"Property/Apple" = "Manzana";
"Property/Pear" = "Pera";
fr.strings file:
"Property/Apple" = "Pomme";
"Property/Pear" = "Poire";
How do I configure NSLocalizedStringFromFile to read the data from the language specific strings file (en = English, es = Spanish, and fr = French) Fruits entity? How do I configure a NSFetchedResultsController to display the localized languages, once the Application Language is changed inside of the simulator?
Thank you for any suggestions, links, and program code to help me resolve this issue.
Note: The above strings file syntax came from Page 36 of the Core Data Programming Guide.
It works exactly the same for Core Data as it does for the rest of Objective-C or Swift. That's the point. That's why the section of the documentation you're asking about no longer exists in the latest version of the document.
Sit down and create a simple Objective-C (or Swift, but I'm going to type in Objective-C) project with a class with a method like so:
- (NSString *) localizedValue {
return NSLocaledStringFromTable(self.unlocalizedValue, @"ValueLocalizationTable", @"Localized value for unlocalized value");
}
and get that to work. Once you figure out how to get that to work, you'll understand how to use the NSLocaliedStringFromTable functions in Xcode.
On the other hand, stop and ask yourself what you're trying to accomplish "internationalizing" a managed object model. If you want to have multiple read-only different versions of your database for different locals, you don't accomplish that using NSLocalizedStringFromTable. You accomplish that by creating multiple different read-only versions of your database and choosing between them at run time (creating a resource bundle and specifying the different versions for different language values).