In this article you'll learn how to work with the SRT file format.
Index
Introduction
SRT is a subtitle file saved in the SubRip file format with the .srt
extension. SRT files make it possible to add subtitles to video content after it is produced. Each .srt
file has a human-readable format where the subtitles are stored sequentially along with the timing information.
SRT is a file with formatted lines of plain text in groups separated by a blank line. Subtitles are numbered sequentially, starting at 1.
SRT file structure
An SRT file contains subtitles in the following format:
A numeric counter identifying each sequential subtitle. Upon importing an SRT file to Lokalise, this counter is dismissed and then restored during the exporting.
A timecode specifying when the subtitle should appear on the screen, followed by an arrow
-->
, and the timecode saying when it should disappear. The timecode format used ishours:minutes:seconds,milliseconds
with time units fixed to two zero-padded digits and fractions fixed to three zero-padded digits (00:00:00,000
). Timecode is used as a key on Lokalise. Upon exporting translations back, the keys are sorted by the timecodes.Subtitle text which can span one or multiple lines. The text is saved as a translation value on Lokalise.
A blank line containing no text, indicating the end of the current subtitle.
Here's an example of an SRT file:
1
00:02:17,440 --> 00:02:20,375
Senator, we're making
our <b>final</b> approach into {u}Coruscant{/u}.
2
00:02:20,476 --> 00:02:22,501
{b}Very good, {i}Lieutenant{/i}{/b}.
3
00:02:24,948 --> 00:02:26,247 X1:201 X2:516 Y1:397 Y2:423
<font color="#fbff1c">Whose side is time on?</font>
4
00:02:36,389 --> 00:02:39,290 X1:203 X2:511 Y1:359 Y2:431
v
5
00:02:41,000 --> 00:02:43,295
[speaks Icelandic]
6
00:02:45,000 --> 00:02:48,295
[man 3] <i>♪The admiral
begins his expedition♪</i>
Please note that there's no placeholder, plural, or gender support in SRT format.
Formatting
The SRT format supports basic text formatting which is derived from HTML:
Bold —
<b>…</b>
or{b}…{/b}
.Italic —
<i>…</i>
or{i}…{/i}
.Underline —
<u>…</u>
or{u}…{/u}
.Font color —
<font color="color name or #color_code">…</font>
.Line position —
X1:… X2:… Y1:… Y2:…
after the timestamp denotes the text coordinates.
Nested tags are supported as well. Some implementations prefer whole-line formatting only. The formatting could be stored "as-is".
Encoding
There's no character encoding standard for SRT files: it could be Windows-1252, Windows-1251, Unicode, UTF-8, UTF-16, with or without BOM.
Working with SRT files on Lokalise
Importing
To upload an SRT file, open your Lokalise project, proceed to the Upload page and start the uploading process as usual.
Please note that Lokalise will not perform a deep validation of your .srt
file: any file with the valid extension will be accepted. However, if the file has invalid formatting, the corresponding translation keys and values won't be created in your project.
After the file was imported, you can perform translations in the project editor:
Exporting
To export your subtitles back in the .srt
format, proceed to the Download page. Choose SubRip from the File format dropdown:
Since SRT files do not support placeholders or plurals, you won't be able to adjust the Plural format and Placeholder format options. The Order keys by option will be disabled as well because the keys will always be sorted by their timecodes.
Once you are ready, click Build and download to export the translation bundle!