Guides

Translate SRT Captions While Preserving Their Timecodes

Translate caption text by cue number and rebuild a UTF-8 SRT with the original timing lines, with a bilingual sample and a local validation script.

Key takeaway

Apply approved caption translations by ID and preserve timing lines.

On this page
  1. Prepare a translation with stable cue numbers
  2. Rebuild and inspect the file
  3. Keep a separate readability check

Give an AI translator the caption numbers and text. Keep a separate copy of the original timing lines and use those lines when rebuilding the file. This lets you inspect the translation without accepting any timecodes a model happens to return. SubRip stores the cue number, timing and caption text in separate parts of each block. Library of Congress SubRip format description

Prepare a translation with stable cue numbers

Start with a UTF-8 SRT using conventional numbered blocks and a separate timing line. If your draft has a phrase split across two cues, fix the cut against the audio before translating it. Faster Whisper subtitle workflow

For the translation task, send a cue list with a short glossary and context about adjacent lines. An original instruction you can adapt:

Translate the supplied caption text into French. Return a JSON object keyed by the supplied cue numbers. Keep product names and error codes verbatim. Use natural phrasing for the visible cue and retain every key once.

Review the returned text and save just the JSON object. The local script accepts multiple text lines within a cue if they are separated by JSON newline escapes. Empty lines within a cue are rejected because a blank line separates SRT blocks.

Rebuild and inspect the file

Download the source SRT, French text and reconstruction script. Save them together and run:

python translate-srt-cues.py srt-translation-source.srt srt-translation-fr.json translated.srt

On November 11, 2026, the script applied both translations and preserved the timing lines. The translation JSON deliberately lists cue 2 first. The output still starts with cue 1 because the source SRT determines order. The French text was written for this fixture. Generated French SRT

Keep a separate readability check

Play the translated captions with the original clip. A correct translation can be too long for its existing interval. Shorten the wording while preserving the meaning, or adjust the cues in your subtitle editor if the audio allows it. Check names, negatives and error codes against the source.

A missing cue or extra translation key stops the script before it opens the output. Duplicate IDs also stop the run. The script preserves existing timing lines and expects the input to have already been checked for order, duration and overlap. Use a fresh output filename for each revision so the approved copy stays available for comparison.

Sources & references

Written by Modelrovia Editorial. Our standards distinguish official claims from observed results.

How we research and test →