Register | Log-in

How to translate subtitles using Docker (Linux or WSL)

How to create a subtitle in your language simply

This tutorial is kindly provided by rickoyuu. All credits to him.
Last update: 2025-03-13
Notes:
   - Some knowledge on command line tools is required.
   - To proceed, you will need a computer with Docker installed.
  1. Introduction
  2. Ensuring Docker is Installed
  3. Pull Ubuntu Image
  4. Create Container
  5. Install Dependencies that Need it.
  6. Install deepl-cli
  7. Download an English Subtitle of Movie
  8. Extract only dialog text using script that I created
  9. Translate it using deepl-cli
  10. Adjust words so that they are not too standardized
  11. Copy file JUQ-351.srt to new file
  12. Replace translated text to JUQ-351-id.srt
  13. Troubleshooting

Introduction

Hi everyone, are you want to create a subtitle in your language? It’s very smple. I have done and in here I will share how I create subtitle in my language. My language is Indonesian and you can create subtitle in your language. The way I use is free (no cost), I only using free tools. Tools that I used are :

  1. Docker
  2. deepl-cli (without api key)
The flow is: I will give you step-by-step to create a subtitle. I’m sorry if my guide is seems technically.

Ensuring Docker is Installed

Make sure your computer or laptop have installed docker. By the way, I use Linux distro, but if you using Windows you can use WSL. In Linux, you can install docker using their package manager, ex. Ubuntu using apt, OpenSUSE using zypper, Fedora using dnf, and many other.

Pull Ubuntu Image

I use ubuntu focal image, so pull it using command :

    $ docker pull ubuntu:focal

Create Container

Create container:

$ docker run -dit --name ubuntu-focal ubuntu:focal bash
Verify:
    $ docker container ls

Install Dependencies that Need it

Access your container that have created it.

$ docker container exec -it ubuntu-focal bash
    $ apt update && apt install vim wget curl unzip pip less -y

Install deepl-cli

You can visit the project at https://github.com/eggplants/deepl-cli. This tools is no using api-key, so you no need to buy deepl subscription. But deepl have limit only 1500 characters.

    $ pip install deepl-cli
    # Test
    $ deepl -F en -T id -s <<<'Hi there! How are you?.' 
  Hai! Apa kabar?

Download an English Subtitle of Movie

Search movie that you want to create subtitle. For example, I want to create subtitle for JAV ID JUQ-351.
Rename it:
Copy from your computer or laptop to container using command : (My workdir in : /root/works/demo)

    $ docker cp JUQ-351.zip ubuntu-focal:/root/works/demo/JUQ-351.zip
Extract it using unzip command:
	
    $ unzip JUQ-351.zip	

Extract only dialog text using script that I created

Use the script extract-text.sh to extract only dialog text. (see Attachments below)

    $ bash extract-text.sh JUQ-351-en.srt
The output is
Count line of result_dialog.txt:
    $ wc -l result_dialog.txt  
      620 result_dialog.txt

Translate it using deepl-cli

Because there are limits of characters from deepl, we must translate it per 50 lines.

    $ sed -n '1,50p' result_dialog.txt > text.txt
    $ deepl -f text.txt -F en -T id >> translated-text.txt
    $ sed -n '51,100p' result_dialog.txt > text.txt
    $ deepl -f text.txt -F en -T id >> translated-text.txt
Do it until the last dialog text.

Adjust words so that they are not too standardized

Adjust words so that they are not too standardized

Copy file JUQ-351.srt to new file

    cp JUQ-351-en.srt JUQ-351-id.srt

Replace translated text to JUQ-351-id.srt

Using script replace-text.sh

    $ bash replace-text.sh JUQ-351-id.srt translated-text.txt
The result is
If you are still confused, you can ask me (rickoyuu). Have a good try :)

Troubleshooting

If you have translated too much in one day, you might get an error like this.

You can use free online proxy in https://www.sslproxies.org/ and change your user_agent by selecting one of the user agents in https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/User-Agent. Example :
Try again.

    $ deepl -f text.txt -F en -T id -t 30000 -v  >> translated-text.txt
Set timeout (-t) to 30000ms.

Attachments

This zip contains the scripts: rickoyuu_TranslateDocker_scripts.zip