Skip to content

Commit

Permalink
Add support for English translation of Rashi
Browse files Browse the repository at this point in the history
fixes #2
  • Loading branch information
M-Zuber committed Nov 29, 2023
1 parent 89bc500 commit fbf44e7
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
15 changes: 10 additions & 5 deletions index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,13 @@ async function getShnayimMikrah(args: Args) {
const {
0: { data: chumash },
1: { data: targum },
2: { data: rashi }
2: { data: rashi },
3: { data: rashiEnglish },
} = await Promise.all([
Axios.get<TextResponse>(`https://www.sefaria.org/api/texts/${range}?context=0&ven=${args.englishTextVersion}&vhe=${args.hebrewTextVersion}`),
Axios.get<TargumResponse>(`https://www.sefaria.org/api/texts/Onkelos_${range}?context=0`),
Axios.get<RashiResponse>(`https://www.sefaria.org/api/texts/Rashi_on_${range}?context=0`)
Axios.get<RashiResponse>(`https://www.sefaria.org/api/texts/Rashi_on_${range}?context=0`),
Axios.get<RashiResponse>(`https://www.sefaria.org/api/texts/Rashi_on_${range}?context=0&lang=en`)
]);
let aliyah: Aliyah = {
verseRange: range,
Expand All @@ -38,7 +40,8 @@ async function getShnayimMikrah(args: Args) {
englishText: chumash.text,
hebrewText: chumash.he as string,
rashi: rashi.he as string[],
targum: targum.he as string
targum: targum.he as string,
rashiEnglish: rashiEnglish.text as string[]
})
}
// All Pasukim are in the same perek.
Expand All @@ -50,7 +53,8 @@ async function getShnayimMikrah(args: Args) {
englishText: t,
hebrewText: chumash.he[i] as string,
rashi: rashi.he[i] as string[],
targum: targum.he[i] as string
targum: targum.he[i] as string,
rashiEnglish: rashiEnglish.text[i] as string[]
}));
}
// Multiple Perakim
Expand All @@ -68,7 +72,8 @@ async function getShnayimMikrah(args: Args) {
englishText: t,
hebrewText: (chumash.he as string[][])[oi][i],
rashi: (rashi.he as string[][][])[oi][i],
targum: (targum.he as string[][])[oi][i]
targum: (targum.he as string[][])[oi][i],
rashiEnglish: (rashiEnglish.text as string[][][])[oi][i]
})
});
});
Expand Down
17 changes: 15 additions & 2 deletions offlineSupport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,17 @@ const rashiLinks = {
[BookName.Deuteronomy]: getRashiLink(BookName.Deuteronomy),
};

const rashiEnglishVersion: RashiVersionOptions = 'Rashi Chumash, Metsudah Publications, 2009';
const baseRashiEnglishLink = `https://raw.githubusercontent.com/Orthodox-Union/ShnayimMikrah-Files/master/Rashi/$book/English/${rashiEnglishVersion}.json`;
const getRashiEnglishLink = (book: BookName) => encodeURI(baseRashiEnglishLink.replace('$book', book));
const rashiEnglishLinks = {
[BookName.Genesis]: getRashiEnglishLink(BookName.Genesis),
[BookName.Exodus]: getRashiEnglishLink(BookName.Exodus),
[BookName.Leviticus]: getRashiEnglishLink(BookName.Leviticus),
[BookName.Numbers]: getRashiEnglishLink(BookName.Numbers),
[BookName.Deuteronomy]: getRashiEnglishLink(BookName.Deuteronomy),
};

/**
* Will download a book with commentaries.
* @param {DownloadArgs} args Options to be used while downloading the Book
Expand All @@ -46,6 +57,7 @@ async function downloadBook(args: DownloadArgs) {
const { data: { text: englishBookText, he: hebrewBookText } } = await Axios.get<ChumashTextResponse>(getChumashLink(book, hebrewTextVersion, englishTextVersion));
const { data: { text: targumText } } = await Axios.get<RawFileDownloadResponse<string[][]>>(targumLinks[book]);
const { data: { text: rashiText } } = await Axios.get<RawFileDownloadResponse<string[][][]>>(rashiLinks[book]);
const { data: { text: rashiEnglishText } } = await Axios.get<RawFileDownloadResponse<string[][][]>>(rashiEnglishLinks[book]);

const verseIndexMapper: Record<string, number> = {};
let k = 0;
Expand All @@ -61,8 +73,9 @@ async function downloadBook(args: DownloadArgs) {
hebrewText: id,
englishText: englishBookText[i][ii],
targum: targumText[i][ii],
rashi: rashiText[i][ii]
}
rashi: rashiText[i][ii],
rashiEnglish: rashiEnglishText[i][ii]
};
})
);
const parshiot = parshiotArray
Expand Down
2 changes: 2 additions & 0 deletions types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,7 @@ export interface ShnayimMikrahVerse {
englishText: string;
targum: string;
rashi: string[];
rashiEnglish: string[];
}
export interface Aliyah {
book: BookName;
Expand Down Expand Up @@ -194,6 +195,7 @@ export type HebrewTextVersionOptions = 'Miqra_according_to_the_Masorah';
export type EnglishTextVersionOptions = 'The_Koren_Jerusalem_Bible';
export type TargumVersionOptions = 'Sifsei Chachomim Chumash, Metsudah Publications, 2009';
export type RashiVersionOptions = 'Rashi Chumash, Metsudah Publications, 2009';
export type RashiEnglishVersionOptions = 'Rashi Chumash, Metsudah Publications, 2009';

/**
* Options to be used when downloading offline data
Expand Down

0 comments on commit fbf44e7

Please sign in to comment.