Skip to content
This repository has been archived by the owner on Jul 4, 2023. It is now read-only.

hsnfirdaus/subtitle-google-translator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Subtitle Google Translator

A php library to translate subtitle srt format with google translate.

Installation

Using Composer

It's recomended to install this library by Composer :

composer require hsnfirdaus/subtitle-google-translator

Manual Installation

You can just manually download this repository as zip and extract to your project directory and include the src/SubtitleTranslator.php file.

Calling the class

You can call this sdk class like this :

require __DIR__ . '/vendor/autoload.php';
$translator = new Hsnfirdaus\SubtitleTranslator($source_lang,$target_lang);

Parameters on Calling

Parameter Type Default Value Details
$source_lang string auto The source language code (en,id,da, e.t.c)
$target_lang string id The target language code (en,id,da, e.t.c)

Response

The response of method on this class is raw srt.

Note

Input subtitle type must be srt and output type will be srt to.

Usage

From Raw

$translator = new Hsnfirdaus\SubtitleTranslator($source_lang,$target_lang);
$translated = $translator->fromRaw($raw_subtitle);
echo $translated;

Parameters

Parameter Type Default Value Details
$raw_subtitle string null The raw text from subtitle.

From File

$translator = new Hsnfirdaus\SubtitleTranslator($source_lang,$target_lang);
$translated = $translator->fromFile($file_path);
echo $translated;

Parameters

Parameter Type Default Value Details
$file_path string null The realpath of subtitle file.

About

Php subtitle translator using Google Translate

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages