+ row_key = dict(table=cls.__tablename__, row_id=unicode(row.id))
+
+ name = row.name
+ writer.add_document(name=name.lower(),
+ display_name=name,
+ **row_key)
+ speller_entries.append((name.lower(), 1))
+
+ # Pokemon also get other languages
+ for foreign_name in getattr(row, 'foreign_names', []):
+ moonspeak = foreign_name.name
+ if name == moonspeak:
+ # Don't add the English name again as a different language;
+ # no point and it makes spell results confusing
+ continue
+
+ writer.add_document(name=moonspeak.lower(),
+ language=foreign_name.language.name,
+ display_name=moonspeak,
+ **row_key)
+ speller_entries.append((moonspeak.lower(), 3))
+
+ # Add Roomaji too
+ if foreign_name.language.name == 'Japanese':
+ roomaji = romanize(foreign_name.name)
+ writer.add_document(name=roomaji.lower(),
+ language='Roomaji',
+ display_name=roomaji,
+ **row_key)
+ speller_entries.append((roomaji.lower(), 8))