subtitle-translator

2025

A command-line Node.js tool that translates .srt subtitle files while preserving their timecode structure. Rather than treating the file as a flat block of text, it parses each subtitle entry individually so line numbers, timestamps, and formatting stay intact after translation — only the spoken text changes. The project was built primarily with Albanian in mind. Classical machine translation (like Google Translate) tends to struggle with Albanian specifically — verb conjugation, register, and idiom don't map cleanly from English, and Albanian is a comparatively low-resource language for most MT training data. Using an LLM (via Groq) instead of a dictionary-style translator allows the prompt to steer tone and phrasing rather than translating word-for-word, producing noticeably more natural output. That said, the tool isn't Albanian-specific under the hood — the target language is just a line in the AI prompt, so it works for any language pair the underlying model supports. Translation runs through the Groq API with a batching system to keep large files from hitting rate limits, along with a fixed delay between calls. This is a demo/proof-of-concept project rather than a production pipeline — it works well for typical dialogue-style subtitles, but batches are currently translated independently, so very long files can see minor inconsistency in tone or terminology across batch boundaries. Example (English → Albanian):
Input (en):
1
00:00:01,000 --> 00:00:03,500
Hey, are you coming tonight?

2
00:00:03,600 --> 00:00:06,000
I don't think I can make it.

Output (sq):
1
00:00:01,000 --> 00:00:03,500
Hej, po vjen sonte?

2
00:00:03,600 --> 00:00:06,000
Nuk mendoj se mund ta bëj.