i want a multilingual coredata db during my apple iphone application. I possibly could create different database for every language but hopefully in apple iphone sdk exist an instantly method to manage data in various language core data like for assets and string.

Someone possess some hints?

I have done something such as Shortseller, but without using groups.

alt text

InternationalBook and LocalizedBook are generally custom handled objects having a one-to-many relationship (one worldwide book to a lot of localized books).

Within the implementation of InternationalBook, I have added a custom accessor for title:

- (NSString *)title {
    [self willAccessValueForKey:@"title"];
    NSString *locTitle = nil;
    NSPredicate *predicate = [NSPredicate predicateWithFormat:@"locale==%@", [DataManager localeString]];
    NSSet *localizedSet = [self.localizedBook filteredSetUsingPredicate:predicate];
    if ([localizedSet count] > 0) {
        locTitle = [[localizedSet valueForKey:@"localizedTitle"] anyObject];
    }
    [self didAccessValueForKey:@"title"];
    return locTitle;
}

[DataManager localeString] is really a class method which returns anyone's language and country code: en_US, fr_FR, etc. See documentation on NSLocale for particulars.

Begin to see the "Custom Attribute and also to-One Relationship Accessor Techniques" portion of the Core Data Programming Guide to have an explanation of willAccessValueForKey: and didAccessValueForKey:.

When inhabiting the information, I grab a string representing anyone's current locale ([DataManager localeString]), and store that across the with localized book title inside a new LocalizedBook object. Each LocalizedBook instance is put into an NSMutableSet, which signifies the main one-to-many relationship.

NSMutableSet *bookLocalizations = [internationalBook mutableSetValueForKey:@"localizedBook"]; // internationalBook is an instance of InternationalBook
// set the values for locale and localizedTitle
LocalizedBook *localizedBook = (LocalizedBook *)[NSEntityDescription insertnNewObjectEntityForName:@"LocalizedBook" inManagedObjectContext:self.bookMOC];
localizedBook.locale = [DataManager localeString];
localizedBook.localizedTitle = theLocalizedTitle; // assume theLocalizedTitle has been defined.
[bookLocalizations addObject:localizedBook];
[bookLocalizations setValue:localizedBook forKey:@"localizedBook"];

Because the localized game titles are now being saved within the LocalizedBook handled object, you may make the title attribute a transient, but when you accomplish that you cannot use title inside a predicate.

The excellent factor relating to this approach would be that the implementation from the to-many relationship is transparent to the customers. You just request internationalBook.title and also the custom accessor returns the right value in line with the user's locale behind the curtain.

I've produced model courses of instruction for the core data organizations.
I Quickly defined category assistant classes with functions to create and obtain the multilanguage qualities (e.g. title).
So I've got a Product (with e.g. code and cost) along with a ProductLanguage (with language and title qualities) Entity.
I never directly access ProductLanguage, but always employ the title function defined around the the merchandise model (via category). It has labored well for me personally sofar.