def cache_translations(objects, languages=None, meta=None):
 if (not objects):
  return objects
 languages = set((languages or ()))
 if (meta is None):
  meta = objects[0]._parler_meta.root
 xlate_model = meta.model
 object_map = dict(((object.pk, object) for object in objects))
 languages.update(set((object._current_language for object in objects)))
 master_ids = object_map.keys()
 for master_ids in batch(master_ids, 950):
  for translation in xlate_model.objects.filter(master_id__in=master_ids, language_code__in=languages):
   master = object_map[translation.master_id]
   master._translations_cache[xlate_model][translation.language_code] = translation
   setattr(translation, translation.__class__.master.cache_name, master)
 return objects

def cache_translations ( objects , languages = None , meta = None ) : if ( not objects ) : return objects languages = set ( ( languages or ( ) ) ) if ( meta is None ) : meta = objects [ 0 ] . _parler_meta . root xlate_model = meta . model object_map = dict ( ( ( object . pk , object ) for object in objects ) ) languages . update ( set ( ( object . _current_language for object in objects ) ) ) master_ids = object_map . keys ( ) for master_ids in batch ( master_ids , 950 ) : for translation in xlate_model . objects . filter ( master_id__in = master_ids , language_code__in = languages ) : master = object_map [ translation . master_id ] master . _translations_cache [ xlate_model ] [ translation . language_code ] = translation setattr ( translation , translation . __class__ . master . cache_name , master ) return objects
cache translation objects in given languages to the objects in one fell swoop .