Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you're going to Core Data, you should generally go all the way. In that case, you would have an NSManagedObject Ingredient. I would probably put a method on Ingredient like <code>stringValueForLocale:</code> that would take care of returning me the best value. This means that a given ingredient can be translated once and is reusable for all recipes.</p> <p>You would then have a Component entity that would have an Ingredient, a quantity value and a unit. A Recipe would have a 1:M property <code>components</code> that would point to these. <code>Component</code> should likely have an <code>englishDescription</code> as well, which would return a printable value like "1/4c sugar" while <code>frenchDescription</code> might print "50g de sucre" (note the volume/mass conversion there; Component is probably where you'd manage this.)</p> <p>Instructions are a bit different, since they are less likely to be reusable. I guess you might get lucky and "Beat eggs to hard peaks." might show up in several recipes, but unless you're going to actively look for those kinds of reuse, it's probably more trouble than it's worth. Instructions are also the natural place to address cultural differences. In France, eggs are often stored at room temperature. In America, they are always refrigerated. To correctly translate a French recipe to American English, you sometimes have to include an extra step like "bring eggs to room temperature." (But it depends on the recipe, since it doesn't always matter.) It generally makes sense to do this in the instructions rather than in the Ingredients.</p> <p>I'd probably create an <code>Instructions</code> entity with <code>stringValuesForLocale:</code> (that would return an array of strings). Then you could do some profiling and decide whether to break this up into separate <code>LocalizedInstructions</code> entities so that you didn't have to fault all of the localization. The advantage of this design is that you can change you mind later about the internal database layout, and it doesn't impact higher levels. In either case, however, I'd probably store the actual instructions as an NSData encoding an NSArray. It's probably not worth the trouble and cost of creating a bunch of individual <code>LocalizedInstruction</code> entities.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload