Tutorials6 min read

Translate Subtitles to Any Language — Privately, in Your Browser

Subtitle translation that never uploads your transcript: how an in-browser LLM translates SRT cue-by-cue, why timing is preserved, and how to pick a target language.

Captions make video accessible; translated captions make it global. The catch with most translation tools is that you paste your transcript into someone else's server. If the video is unreleased, internal, or sensitive, that is a problem. Here is how subtitle translation works when the language model runs on your own machine.

SRT is just timed text

An SRT file is a list of cues. Each cue has an index, a start and end timestamp, and one or two lines of text:

12
00:01:04,500 --> 00:01:07,000
We shipped the update last night.

Translation must change the text while leaving the timestamps untouched — otherwise the words drift out of sync with the picture. So the first step is parsing: split the file into cues, keep each cue's timing aside, and translate only the text.

Translating cue-by-cue (in batches)

A naive approach translates each line in its own request, which is slow and loses context — "it" in one cue might refer to a noun in the previous one. A better approach batches several cues into a single numbered prompt and asks the model to return a numbered list back, so context is shared and the mapping back to timestamps stays exact.

When the translation runs through an in-browser LLM (WebLLM), the prompt and the transcript never leave the page. The model weights download once and then run on your GPU. After the first load it even works offline.

Picking a target language

You can drive the target language two ways:

  • Pick a preset — Spanish, French, German, Portuguese, Japanese, Chinese — which sets the language code directly.
  • Just type it — "translate to French" is parsed into the right language automatically, so the prompt box alone is enough.

Either way, the source language is auto-detected from the text; you only choose where you are going.

Where machine translation still needs a human

Automatic subtitle translation is excellent for getting 90% of the way there fast, but two things deserve a human pass:

  • Idioms and tone. "Break a leg" should not become a medical instruction. A reviewer fluent in the target language catches these.
  • Reading speed. Some languages are wordier than others. If a translated line is much longer than the original, it may flash by too fast — consider shortening it or extending the cue.

Export the translated SRT, drop it back onto your video, and you have localized captions without a single byte leaving your browser.