Skip to content

Commit

Permalink
Make Tanakh Yomi translations work correctly
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Jan 28, 2024
1 parent 059379c commit bac92bc
Show file tree
Hide file tree
Showing 9 changed files with 543 additions and 68 deletions.
129 changes: 107 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Supports several learning schedules
* Daf Yomi (Babylonian Talmud / Bavli) - `dafYomi`
* Mishna Yomi - `mishnaYomi`
* Nach Yomi - `nachYomi`
* Tanakh Yomi - `tanakhYomi`
* Psalms / Tehillim (30 day cycle) - `psalms`
* Yerushalmi Yomi (Jerusalem Talmud)
* Vilna edition - `yerushalmi-vilna`
Expand Down Expand Up @@ -35,19 +36,18 @@ const hd = new HDate(dt);
const ev = DailyLearning.lookup('dafYomi', hd);
console.log(dt.toLocaleDateString(), hd.toString(), ev.render('en'));
```

## Classes

<dl>
<dt><a href="#DafPage">DafPage</a></dt>
<dd><p>Represents a tractate and page number</p>
</dd>
<dt><a href="#DafYomi">DafYomi</a></dt>
<dd><p>Returns the Daf Yomi for given date</p>
</dd>
<dt><a href="#DafPageEvent">DafPageEvent</a></dt>
<dd><p>Event wrapper around a DafPage instance</p>
</dd>
<dt><a href="#DafYomi">DafYomi</a></dt>
<dd><p>Returns the Daf Yomi for given date</p>
</dd>
<dt><a href="#DafYomiEvent">DafYomiEvent</a></dt>
<dd><p>Event wrapper around a DafYomi instance</p>
</dd>
Expand Down Expand Up @@ -83,6 +83,12 @@ and Ketuvim (Writings).</p>
<dt><a href="#DafWeeklyEvent">DafWeeklyEvent</a></dt>
<dd><p>Event wrapper around a daily weekly</p>
</dd>
<dt><a href="#TanakhYomi">TanakhYomi</a></dt>
<dd><p>Returns the Daf Yomi for given date</p>
</dd>
<dt><a href="#TanakhYomiEvent">TanakhYomiEvent</a></dt>
<dd><p>Event wrapper around a tanakhYomi</p>
</dd>
</dl>

## Constants
Expand Down Expand Up @@ -127,6 +133,9 @@ cycle began (2 February 1980 for Vilna,
<dt><a href="#dafWeekly">dafWeekly(date)</a> ⇒ <code><a href="#DafPage">DafPage</a></code></dt>
<dd><p>Daf-a-Week</p>
</dd>
<dt><a href="#tanakhYomi">tanakhYomi(date)</a> ⇒ <code><a href="#TanakhYomi">TanakhYomi</a></code></dt>
<dd><p>Calculates Tanakh Yomi.</p>
</dd>
</dl>

## Typedefs
Expand Down Expand Up @@ -183,22 +192,6 @@ Formats (with translation) the dafyomi result as a string like "Pesachim 34"
| --- | --- | --- |
| [locale] | <code>string</code> | Optional locale name (defaults to active locale). |

<a name="DafYomi"></a>

## DafYomi
Returns the Daf Yomi for given date

**Kind**: global class
<a name="new_DafYomi_new"></a>

### new DafYomi(date)
Initializes a daf yomi instance


| Param | Type | Description |
| --- | --- | --- |
| date | <code>Date</code> \| <code>HDate</code> \| <code>number</code> | Gregorian or Hebrew date |

<a name="DafPageEvent"></a>

## DafPageEvent
Expand All @@ -207,19 +200,20 @@ Event wrapper around a DafPage instance
**Kind**: global class

* [DafPageEvent](#DafPageEvent)
* [new DafPageEvent(date, daf)](#new_DafPageEvent_new)
* [new DafPageEvent(date, daf, mask)](#new_DafPageEvent_new)
* [.render([locale])](#DafPageEvent+render) ⇒ <code>string</code>
* [.renderBrief([locale])](#DafPageEvent+renderBrief) ⇒ <code>string</code>
* [.url()](#DafPageEvent+url) ⇒ <code>string</code>

<a name="new_DafPageEvent_new"></a>

### new DafPageEvent(date, daf)
### new DafPageEvent(date, daf, mask)

| Param | Type |
| --- | --- |
| date | <code>HDate</code> |
| daf | [<code>DafPage</code>](#DafPage) |
| mask | <code>number</code> |

<a name="DafPageEvent+render"></a>

Expand Down Expand Up @@ -249,6 +243,22 @@ Returns Daf Yomi name without the 'Daf Yomi: ' prefix (e.g. "Pesachim 107").
Returns a link to sefaria.org or dafyomi.org

**Kind**: instance method of [<code>DafPageEvent</code>](#DafPageEvent)
<a name="DafYomi"></a>

## DafYomi
Returns the Daf Yomi for given date

**Kind**: global class
<a name="new_DafYomi_new"></a>

### new DafYomi(date)
Initializes a daf yomi instance


| Param | Type | Description |
| --- | --- | --- |
| date | <code>Date</code> \| <code>HDate</code> \| <code>number</code> | Gregorian or Hebrew date |

<a name="DafYomiEvent"></a>

## DafYomiEvent
Expand Down Expand Up @@ -685,6 +695,70 @@ Event wrapper around a daily weekly

### dafWeeklyEvent.getCategories() ⇒ <code>Array.&lt;string&gt;</code>
**Kind**: instance method of [<code>DafWeeklyEvent</code>](#DafWeeklyEvent)
<a name="TanakhYomi"></a>

## TanakhYomi
Returns the Daf Yomi for given date

**Kind**: global class

* [TanakhYomi](#TanakhYomi)
* [new TanakhYomi(name, blatt)](#new_TanakhYomi_new)
* [.render([locale])](#TanakhYomi+render) ⇒ <code>string</code>

<a name="new_TanakhYomi_new"></a>

### new TanakhYomi(name, blatt)
Initializes a daf yomi instance


| Param | Type |
| --- | --- |
| name | <code>string</code> |
| blatt | <code>number</code> |

<a name="TanakhYomi+render"></a>

### tanakhYomi.render([locale]) ⇒ <code>string</code>
Formats (with translation) the dafyomi result as a string like "Pesachim 34"

**Kind**: instance method of [<code>TanakhYomi</code>](#TanakhYomi)

| Param | Type | Description |
| --- | --- | --- |
| [locale] | <code>string</code> | Optional locale name (defaults to active locale). |

<a name="TanakhYomiEvent"></a>

## TanakhYomiEvent
Event wrapper around a tanakhYomi

**Kind**: global class

* [TanakhYomiEvent](#TanakhYomiEvent)
* [new TanakhYomiEvent(date, daf)](#new_TanakhYomiEvent_new)
* [.url()](#TanakhYomiEvent+url) ⇒ <code>string</code>
* [.getCategories()](#TanakhYomiEvent+getCategories) ⇒ <code>Array.&lt;string&gt;</code>

<a name="new_TanakhYomiEvent_new"></a>

### new TanakhYomiEvent(date, daf)

| Param | Type |
| --- | --- |
| date | <code>HDate</code> |
| daf | [<code>TanakhYomi</code>](#TanakhYomi) |

<a name="TanakhYomiEvent+url"></a>

### tanakhYomiEvent.url() ⇒ <code>string</code>
Returns a link to sefaria.org or dafyomi.org

**Kind**: instance method of [<code>TanakhYomiEvent</code>](#TanakhYomiEvent)
<a name="TanakhYomiEvent+getCategories"></a>

### tanakhYomiEvent.getCategories() ⇒ <code>Array.&lt;string&gt;</code>
**Kind**: instance method of [<code>TanakhYomiEvent</code>](#TanakhYomiEvent)
<a name="vilna"></a>

## vilna
Expand Down Expand Up @@ -778,6 +852,17 @@ Daf-a-Week
| --- | --- | --- |
| date | <code>HDate</code> \| <code>Date</code> \| <code>number</code> | Hebrew or Gregorian date |

<a name="tanakhYomi"></a>

## tanakhYomi(date) ⇒ [<code>TanakhYomi</code>](#TanakhYomi)
Calculates Tanakh Yomi.

**Kind**: global function

| Param | Type | Description |
| --- | --- | --- |
| date | <code>HDate</code> \| <code>Date</code> \| <code>number</code> | Hebrew or Gregorian date |

<a name="MishnaYomi"></a>

## MishnaYomi : <code>Object</code>
Expand Down
38 changes: 19 additions & 19 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/learning",
"version": "5.0.4",
"version": "5.0.5",
"description": "Daily learning schedules: Daf Yomi, Mishna Yomi, etc",
"main": "dist/index.cjs",
"module": "dist/index.mjs",
Expand Down Expand Up @@ -38,7 +38,7 @@
"build": "npm run po2json && npm run build:json2js && npm run build:rollup",
"prepublish": "npm run build",
"pretest": "npm run build",
"readme": "npx -p jsdoc-to-markdown jsdoc2md dist/index.js",
"readme": "cp dist/index.mjs tmp.js && npx -p jsdoc-to-markdown jsdoc2md tmp.js",
"test": "ava"
},
"devDependencies": {
Expand Down
16 changes: 16 additions & 0 deletions po/he.po
Original file line number Diff line number Diff line change
Expand Up @@ -652,3 +652,19 @@ msgstr "שער התורה"

msgid "Chasimas Hasefer"
msgstr "חתימת הספר"

# Tanakh Yomi
msgid "Kings"
msgstr "מְלָכִים"

msgid "Minor Prophets"
msgstr "תרי עשר"

msgid "Ezra and Nehemiah"
msgstr "עֶזְרָא וְנְחֶמְיָה"

msgid "Chronicles"
msgstr "דִברֵי הַיָמִים"

msgid "Samuel"
msgstr "שְׁמוּאֵל"
10 changes: 2 additions & 8 deletions src/MishnaYomiEvent.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import test from 'ava';
import {MishnaYomiEvent} from './MishnaYomiEvent.js';
import {HDate, Locale} from '@hebcal/core';
import poAshkenazi from './ashkenazi.po.js';
import poHe from './he.po.js';

Locale.addTranslations('ashkenazi', poAshkenazi);
Locale.addTranslations('a', poAshkenazi);
Locale.addTranslations('he', poHe);
Locale.addTranslations('h', poHe);
import {HDate} from '@hebcal/core';
import './locale.js';

test('MishnaYomiEvent-url', (t) => {
const my = [{k: 'Berakhot', v: '3:6'}, {k: 'Berakhot', v: '4:1'}];
Expand Down
19 changes: 19 additions & 0 deletions src/locale.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import {Locale} from '@hebcal/core';
import poHe from './he.po.js';
import poAshkenazi from './ashkenazi.po.js';

Locale.addTranslations('he', poHe);
Locale.addTranslations('h', poHe);
Locale.addTranslations('ashkenazi', poAshkenazi);
Locale.addTranslations('a', poAshkenazi);

const heStrs = poHe.contexts[''];
const heNoNikud = {};
for (const [key, val] of Object.entries(heStrs)) {
heNoNikud[key] = [Locale.hebrewStripNikkud(val[0])];
}
const poHeNoNikud = {
headers: poHe.headers,
contexts: {'': heNoNikud},
};
Locale.addTranslations('he-x-NoNikud', poHeNoNikud);
Loading

0 comments on commit bac92bc

Please sign in to comment.