Skip to content

Commit

Permalink
Add headings
Browse files Browse the repository at this point in the history
  • Loading branch information
pyrossh committed Jun 3, 2024
1 parent 2f1f549 commit cbd9ab3
Show file tree
Hide file tree
Showing 14 changed files with 30,286 additions and 29,160 deletions.
5,832 changes: 2,916 additions & 2,916 deletions assets/bibles/Bengali.txt

Large diffs are not rendered by default.

5,832 changes: 2,916 additions & 2,916 deletions assets/bibles/Gujarati.txt

Large diffs are not rendered by default.

5,832 changes: 2,916 additions & 2,916 deletions assets/bibles/Hindi.txt

Large diffs are not rendered by default.

5,832 changes: 2,916 additions & 2,916 deletions assets/bibles/Kannada.txt

Large diffs are not rendered by default.

5,832 changes: 2,916 additions & 2,916 deletions assets/bibles/Malayalam.txt

Large diffs are not rendered by default.

5,832 changes: 2,916 additions & 2,916 deletions assets/bibles/Nepali.txt

Large diffs are not rendered by default.

5,832 changes: 2,916 additions & 2,916 deletions assets/bibles/Oriya.txt

Large diffs are not rendered by default.

5,818 changes: 2,909 additions & 2,909 deletions assets/bibles/Punjabi.txt

Large diffs are not rendered by default.

5,832 changes: 2,916 additions & 2,916 deletions assets/bibles/Tamil.txt

Large diffs are not rendered by default.

5,832 changes: 2,916 additions & 2,916 deletions assets/bibles/Telugu.txt

Large diffs are not rendered by default.

35 changes: 35 additions & 0 deletions scripts/main.js
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")
Loading

0 comments on commit cbd9ab3

Please sign in to comment.