parameters: (csv_file, glossaries, locale, po_file)
return_statement: return hits
docstring: Run the actual check.
docstring_summary: Run the actual check.
docstring_tokens: Run the actual check .
function: def check_file(csv_file, glossaries, locale, po_file):
      """Run the actual check."""
      translations = read_csv_file(csv_file)
      source_index = 0
      target_index = 0
      location_index = 0
      hits = []
      counter = 0
      hunspell_locale = get_hunspell_locale(locale)
      for row in translations:
          # Detect the column indices
          if counter == 0:
              colum_counter = 0
              for header in row:
                  if header == 'source':
                      source_index = colum_counter
                  elif header == 'target':
                      target_index = colum_counter
                  elif header == 'location':
                      location_index = colum_counter
                  colum_counter = colum_counter + 1
          else:
              for entry in glossaries[locale]:
                  # Check if the source text contains the glossary term.
                  # Filter out superstrings, e.g. we don't want to check
                  # "arena" against "battle arena"
                  if source_contains_term(row[source_index], entry, glossaries[locale]):
                      # Skip empty translations
                      if row[target_index] == '':
                          continue
                      # Now verify the translation against all translation
                      # variations from the glossary
                      term_found = translation_has_term(entry, row[target_index])
                      # Add Hunspell stems for better matches and try again
                      # We do it here because the Hunspell manipulation is slow.
                      if not term_found and hunspell_locale != '':
                          target_to_check = append_hunspell_stems(
                              hunspell_locale, row[target_index])
                          term_found = translation_has_term(
                              entry, target_to_check)
                      if not term_found:
                          hit = FailedTranslation()
                          hit.source = row[source_index]
                          hit.target = row[target_index]
                          hit.location = row[location_index]
                          hit.term = entry.terms[0]
                          hit.translation = entry.translations[0]
                          hit.locale = locale
                          hit.po_file = po_file
                          hits.append(hit)
          counter = counter + 1
      return hits
function_tokens: def check_file ( csv_file , glossaries , locale , po_file ) : translations = read_csv_file ( csv_file ) source_index = 0 target_index = 0 location_index = 0 hits = [ ] counter = 0 hunspell_locale = get_hunspell_locale ( locale ) for row in translations : # Detect the column indices if counter == 0 : colum_counter = 0 for header in row : if header == 'source' : source_index = colum_counter elif header == 'target' : target_index = colum_counter elif header == 'location' : location_index = colum_counter colum_counter = colum_counter + 1 else : for entry in glossaries [ locale ] : # Check if the source text contains the glossary term. # Filter out superstrings, e.g. we don't want to check # "arena" against "battle arena" if source_contains_term ( row [ source_index ] , entry , glossaries [ locale ] ) : # Skip empty translations if row [ target_index ] == '' : continue # Now verify the translation against all translation # variations from the glossary term_found = translation_has_term ( entry , row [ target_index ] ) # Add Hunspell stems for better matches and try again # We do it here because the Hunspell manipulation is slow. if not term_found and hunspell_locale != '' : target_to_check = append_hunspell_stems ( hunspell_locale , row [ target_index ] ) term_found = translation_has_term ( entry , target_to_check ) if not term_found : hit = FailedTranslation ( ) hit . source = row [ source_index ] hit . target = row [ target_index ] hit . location = row [ location_index ] hit . term = entry . terms [ 0 ] hit . translation = entry . translations [ 0 ] hit . locale = locale hit . po_file = po_file hits . append ( hit ) counter = counter + 1 return hits