WebVTT subtitles
AI translation for WebVTT subtitle files with Lingo.dev CLI
What are WebVTT subtitles?
WebVTT (Web Video Text Tracks) subtitles are a format for displaying timed text tracks with HTML5 video. They support styling, positioning, and metadata, making them more feature-rich than SRT.
For example:
WEBVTT
NOTE
Product demonstration video with captions
1
00:00:01.000 --> 00:00:03.500
Welcome to our software tutorial
subtitle-2
00:00:04.000 --> 00:00:07.200
Let's explore the main features
3
00:00:08.500 --> 00:00:12.000 align:middle line:90%
Here's how to create your first project
What is Lingo.dev CLI?
Lingo.dev CLI is a free, open-source CLI for translating apps and content with AI. It's designed to replace traditional translation management software while integrating with existing pipelines.
To learn more, see Overview.
About this guide
This guide explains how to translate WebVTT subtitle files with Lingo.dev CLI.
You'll learn how to:
- Create a project from scratch
- Configure a translation pipeline
- Generate translations with AI
Prerequisites
To use Lingo.dev CLI, ensure that Node.js v18+ is installed:
❯ node -v
v22.17.0
Step 1. Set up a project
In your project's directory, create an i18n.json file:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
This file defines the behavior of the translation pipeline, including what languages to translate between and where the localizable content exists on the file system.
To learn more about the available properties, see i18n.json.
Step 2. Configure the source locale
The source locale is the original language and region that your content was written in. To configure the source locale, set the locale.source property in the i18n.json file:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
The source locale must be provided as a BCP 47 language tag.
For the complete list of the locale codes that Lingo.dev CLI supports, see Supported locale codes.
Step 3. Configure the target locales
The target locales are the languages and regions you want to translate your content into. To configure the target locales, set the locale.targets property in the i18n.json file:
{
"$schema": "https://lingo.dev/schema/i18n.json",
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {}
}
Step 4. Create the source content
If you haven't already, create one or more WebVTT subtitle files that contain the content to be translated. These files must be located at a path that includes the source locale somewhere in the path (e.g., as a directory name like en/ or as part of the filename like messages.en.vtt).
Step 5. Create a bucket
-
In the
i18n.jsonfile, add a"vtt"object to thebucketsobject:{ "$schema": "https://lingo.dev/schema/i18n.json", "version": "1.10", "locale": { "source": "en", "targets": ["es"] }, "buckets": { "vtt": {} } } -
In the
"vtt"object, define an array of one or moreincludepatterns:{ "$schema": "https://lingo.dev/schema/i18n.json", "version": "1.10", "locale": { "source": "en", "targets": ["es"] }, "buckets": { "vtt": { "include": ["./[locale]/example.vtt"] } } }These patterns define which files to translate.
The patterns themselves:
- must contain
[locale]as a placeholder for the configured locale - can point to file paths (e.g.,
"[locale]/video.vtt") - can use asterisks as wildcard placeholders (e.g.,
"[locale]/*.vtt")
Recursive glob patterns (e.g.,
**/*.vtt) are not supported. - must contain
Step 6. Configure an LLM
Lingo.dev CLI uses large language models (LLMs) to translate content with AI. To use one of these models, you need an API key from a supported provider.
To get up and running as quickly as possible, we recommend using Lingo.dev Engine — our own, hosted platform that offers 10,000 tokens of free, monthly usage:
-
Run the following command:
npx lingo.dev@latest loginThis will open your default browser and ask you to authenticte.
-
Follow the prompts.
Step 7. Generate the translations
In the directory that contains the i18n.json file, run the following command:
npx lingo.dev@latest run
This command:
- Reads the
i18n.jsonfile. - Finds the files that need to be translated.
- Extracts the translatable content from the files.
- Uses the configured LLM to translate the extracted content.
- Writes the translated content back to the file system.
The first time translations are generated, an i18n.lock file is created. This file keeps track of what content has been translated, preventing unnecessary retranslations on subsequent runs.
Example
en/example.vtt
WEBVTT
NOTE
Product demonstration video with captions
1
00:00:01.000 --> 00:00:03.500
Welcome to our software tutorial
subtitle-2
00:00:04.000 --> 00:00:07.200
Let's explore the main features
3
00:00:08.500 --> 00:00:12.000 align:middle line:90%
Here's how to create your first project
00:00:13.000 --> 00:00:16.500
Click the New Project button
to get started
final-cue
00:00:17.000 --> 00:00:20.000 position:25% align:start
That completes our basic tutorial
es/example.vtt
WEBVTT
NOTE
Video de demostración de producto con subtítulos
1
00:00:01.000 --> 00:00:03.500
Bienvenido a nuestro tutorial de software
subtitle-2
00:00:04.000 --> 00:00:07.200
Exploremos las características principales
3
00:00:08.500 --> 00:00:12.000 align:middle line:90%
Aquí está cómo crear tu primer proyecto
00:00:13.000 --> 00:00:16.500
Haz clic en el botón Nuevo Proyecto
para comenzar
final-cue
00:00:17.000 --> 00:00:20.000 position:25% align:start
Eso completa nuestro tutorial básico
i18n.json
{
"version": "1.10",
"locale": {
"source": "en",
"targets": ["es"]
},
"buckets": {
"vtt": {
"include": ["./[locale]/example.vtt"]
}
},
"$schema": "https://lingo.dev/schema/i18n.json"
}
i18n.lock
version: 1
checksums:
ab6437a18c50af6612bb75499361d64a:
0#1-3.5#1: 5df3c06b74cfc8558e85ff75a30a9162
1#4-7.2#subtitle-2: 0de65f1d2616b6959aa79ac5beb6e84c
2#8.5-12#3: 3351244c032529a099f1191477d9e488
3#13-16.5#: b9341abc965d5178a96d9bc4e8e2c59a
4#17-20#final-cue: 0b67e089cd3f39b8520d7a2be9f34362