title: i18n in iOS Core Data
body: <p>I'm working on a localized schema for iOS. I have different Entities that can have translated fields, so for each one I create a <em>Translation</em> entity. There is always a one-many relation between the two entities, allowing me to add new languages in the future, and I can access the translations via <strong>Entity.translations</strong>. So far so good.</p>
  
  <pre><code>Entity
  EntityTranslation
  </code></pre>
  
  <p>1) First of all, I would like to know if an approach like that sounds good. Is the solution I will use in a pure SQL environment so I suppose I can follow that path.</p>
  
  <p>2) Then... I would like to just use <code>Entity.text</code> for showing the appropriate text for the user (via <code>NSLocale preferredLanguages</code>). As <code>translations</code> returns a <code>NSSet</code> then one option will be to manually add the attribute to the Entity model, and change the getter:</p>
  
  <pre><code>// Entity.h
  @property (nonatomic, retain) NSString * text;
  
  // Entity.m
  @synthesize text;
  
  - (NSString *) text
  {
    NSString *locale = [[NSLocale preferredLanguages] objectAtIndex:0];
  
    NSSet *filteredTranslations = [self.translations filteredSetUsingPredicate: [NSPredicate predicateWithFormat:@"locale = %@", locale]];
    EntityTranslation *translation = [[filteredTranslations allObjects] objectAtIndex:0];
  
    return translation.text;
  }
  </code></pre>
  
  <p>It works, but does it make sense? Can I have performance issues? Is it possible to do something similar using <strong>Fetched properties</strong>? Something tells me that it should be possible but I can't make it work using the Xcode Core Data editor...</p>
  
  <p>Thanks.</p>