Building TranslateFiction

I recently built Translate Fiction with the OpenAI API. It's a simple app to help me translate short fiction and study languages.

Screenshot of the Translate Fiction app v1

This'll stay a side project. I may keep adding features that'll help me learn. Source code is available on GitHub.

The functionality is pretty simple:

  1. Input text in another language
  2. Get a first draft translation in English
  3. Edit the translation as you see fit
  4. Highlight words or phrases that you want to tweak
  5. Get multiple definitions for those words
  6. Improve your translation
  7. Publish and share your work! (off app)

Recently I'd been wanting to take a stab at translating some more short stories, starting with "The Second Bakery Attack" by Haruki Murakami. I like Jay Rubin's translation, but I wanted to try doing it myself (and to try making the language a bit more casual).

I started out with an online dictionary. Then I figured why not use ChatGPT's consumer app to speed things up a bit? It was still pretty slow going though.

Then I had a thought. Why not build a little app with the OpenAI API to save time copy/pasting unfamiliar or ambiguous words and phrases, making edits to improve the "literary quality," etc.?

When I was working on Yaya, my co-founder David did all of the work with the APIs, and I focused on UI/UX and prompt engineering. So this time, I was looking for a simple project to work with the API code myself. This was small enough that I could do it all.

I'd never built anything with the OpenAI API, so I pulled up a YouTube tutorial and started a new Next.js project.

I used Cursor as my IDE and used the AI-powered ⌘K and chat liberally. First I had Cursor generate a simple UI and made some tweaks. Then I followed along with the video to set up an API endpoint to handle requests to the OpenAI API for the translation. Once I got that working, I added the highlight/explain feature and added functionality to handle different types of messages going to the OpenAI API. Then I finished things up by adding keyboard shortcuts (Mac only, sorry) and doing a tiny bit of polish.

Some ideas if I keep working on this:

  • Improve automatic language detection for short highlights by looking at language probabilities
  • Improve the explain feature to look for literary/cultural references
  • Try fine-tuning a model based on my first 10 edited paragraphs to improve generated translation quality
  • Add a settings menu to change models, set temperature, etc.
  • Improve the UX and clean up the code