-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
pyrossh
committed
Jun 3, 2024
1 parent
2f1f549
commit cbd9ab3
Showing
14 changed files
with
30,286 additions
and
29,160 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import fs from "node:fs"; | ||
import { v2 } from '@google-cloud/translate'; | ||
|
||
const translate = new v2.Translate({ | ||
key: "AIzaSyAYS5LdP5_i2AxIJprVQFYzb-7Nk2iJfv8", | ||
}); | ||
|
||
const filename = "Bengali" | ||
const code = "bn" | ||
const outputLines = []; | ||
const data = fs.readFileSync(`../assets/bibles/${filename}.txt`, "utf8"); | ||
const lines = data.split("\n"); | ||
for (const line of lines) { | ||
const arr = line.split("|"); | ||
const book = parseInt(arr[0]); | ||
const chapter = parseInt(arr[1]); | ||
const verseNo = parseInt(arr[2]); | ||
let heading = arr[3]; | ||
const verseText = arr.slice(4, arr.length).join("|"); | ||
if (heading != "") { | ||
const [translation] = await translate.translate(heading, code); | ||
await new Promise((res) => { | ||
setTimeout(res, 2000); | ||
}); | ||
heading = translation; | ||
} | ||
outputLines.push(`${book}|${chapter}|${verseNo}|${heading}|${verseText}`); | ||
if (chapter === 5) { | ||
break; | ||
} | ||
} | ||
|
||
const outputText = outputLines.join("\n") | ||
|
||
fs.writeFileSync(`../assets/bibles/${filename}2.txt`, outputText, "utf8") |
Oops, something went wrong.