def filter_contents_translations(generator):
 inspector = GeneratorInspector(generator)
 current_lang = generator.settings['DEFAULT_LANG']
 langs_with_sites = _SITE_DB.keys()
 removed_contents = _GENERATOR_DB[generator]
 for translations in inspector.translations_lists():
  for translation in translations[:]:
   if (translation.lang in langs_with_sites):
    translations.remove(translation)
    removed_contents.append(translation)
 hiding_func = inspector.hiding_function()
 untrans_policy = inspector.untranslated_policy(default='hide')
 for (contents, other_contents) in inspector.contents_list_pairs():
  for content in other_contents:
   if (content.lang == current_lang):
    _NATIVE_CONTENT_URL_DB[content.source_path] = content.url
  for content in contents[:]:
   if (content.lang == current_lang):
    _NATIVE_CONTENT_URL_DB[content.source_path] = content.url
   elif ((content.lang in langs_with_sites) and (untrans_policy != 'keep')):
    contents.remove(content)
    if (untrans_policy == 'hide'):
     other_contents.append(hiding_func(content))
    elif (untrans_policy == 'remove'):
     removed_contents.append(content)

def filter_contents_translations ( generator ) : inspector = GeneratorInspector ( generator ) current_lang = generator . settings [ 'DEFAULT_LANG' ] langs_with_sites = _SITE_DB . keys ( ) removed_contents = _GENERATOR_DB [ generator ] for translations in inspector . translations_lists ( ) : for translation in translations [ : ] : if ( translation . lang in langs_with_sites ) : translations . remove ( translation ) removed_contents . append ( translation ) hiding_func = inspector . hiding_function ( ) untrans_policy = inspector . untranslated_policy ( default = 'hide' ) for ( contents , other_contents ) in inspector . contents_list_pairs ( ) : for content in other_contents : if ( content . lang == current_lang ) : _NATIVE_CONTENT_URL_DB [ content . source_path ] = content . url for content in contents [ : ] : if ( content . lang == current_lang ) : _NATIVE_CONTENT_URL_DB [ content . source_path ] = content . url elif ( ( content . lang in langs_with_sites ) and ( untrans_policy != 'keep' ) ) : contents . remove ( content ) if ( untrans_policy == 'hide' ) : other_contents . append ( hiding_func ( content ) ) elif ( untrans_policy == 'remove' ) : removed_contents . append ( content )
filter the content and translations lists of a generator filters out 1) translations which will be generated in a different site 2) content that is not in the language of the currently generated site but in that of a different site .