transub

package module
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 30, 2023 License: MIT Imports: 9 Imported by: 0

README

Translate Subtitle File

A simple subtitle translator using my own fork of go-googletrans.

Quick Start Example

Input
// some_subtitle_file_example.srt
3

00:00:16,500 --> 00:00:19,500

[tense jazzy music]

  

4

00:00:19,500 --> 00:00:26,542

♪ ♪

  

5

00:01:48,083 --> 00:01:50,792

- Hello world!

Simple translate

package main

  

import (
	"log"

	transub "github.com/lcapuano-app/go-translate-subtitle-file"
)

  

func  main() {
	opts := transub.Config{
		RemoveCloseCaption: true,
		LanguageSrc: "en",
		LanguageDest: "pt",
		OutputDir: "",
	}

	ts := transub.TransubNew("some_subtitle_file_example.srt", opts)

	if  err := ts.Translaste(); err != nil {
		log.Fatal(err)
	}
}

Output
// some_subtitle_file_example.pt.srt

3

00:00:16,500 --> 00:00:19,500

  

4

00:00:19,500 --> 00:00:26,542

  

5

00:01:48,083 --> 00:01:50,792

- Olá mundo!

Documentation

Index

Constants

View Source
const (
	LN_BREAK = "\n"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	RemoveCloseCaption bool
	LanguageSrc        string
	LanguageDest       string
	OutputDir          string
}

type FileLines

type FileLines struct {
	Originals     []string
	Translatables []string
	Translateds   []string
	TempTrans     []string
}

type Transub

type Transub struct {
	InputFilename  string
	OutputFilename string
	FileExt        string
	Conf           Config
}

func TransubNew

func TransubNew(filename string, config ...Config) *Transub

func (*Transub) CreateOutputFile

func (ts *Transub) CreateOutputFile(fileTextLines FileLines) error

func (*Transub) ExtractFileLines

func (ts *Transub) ExtractFileLines() (originals, translatables []string, err error)

func (*Transub) RemoveLangFromFilename

func (ts *Transub) RemoveLangFromFilename() string

func (*Transub) Translaste

func (ts *Transub) Translaste() error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL