Skip to content

Commit

Permalink
Move Sedra and Hebrew translations back up a level from @hebcal/hdate
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Jun 2, 2024
1 parent ec0d276 commit d8a81f3
Show file tree
Hide file tree
Showing 20 changed files with 3,269 additions and 66 deletions.
2,084 changes: 2,024 additions & 60 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/core",
"version": "5.4.1",
"version": "5.4.2",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"contributors": [
"Eyal Schachter (https://github.com/Scimonster)",
Expand Down Expand Up @@ -46,9 +46,10 @@
],
"scripts": {
"build:rollup": "rollup -c",
"build": "npm run version && npm run build:rollup --production",
"build": "npm run po2json && npm run version && npm run build:rollup --production",
"prepublish": "npm run build",
"version": "node ./version.cjs package.json src/pkgVersion.ts",
"po2json": "node ./po2json.cjs po/*.po",
"readme": "cp dist/index.mjs tmp.js && npx -p jsdoc-to-markdown jsdoc2md tmp.js && rm -f tmp.js",
"pretest": "npm run build",
"lint": "eslint src",
Expand Down Expand Up @@ -79,10 +80,11 @@
"jsdoc-to-markdown": "^8.0.1",
"quick-lru": "^7.0.0",
"rollup": "^4.18.0",
"ttag-cli": "^1.10.12",
"typescript": "^5.4.5"
},
"dependencies": {
"@hebcal/hdate": "^0.9.13",
"@hebcal/hdate": "^0.10.1",
"@hebcal/noaa": "^0.8.14",
"tslib": "^2.6.2"
}
Expand Down
29 changes: 29 additions & 0 deletions po2json.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/* eslint-disable require-jsdoc */
const fs = require('fs');
const path = require('path');
const parser = require('ttag-cli/dist/src/lib/parser');
const utils = require('ttag-cli/dist/src/lib/utils');

for (const arg of process.argv.slice(2)) {
const outpath = './src/' + path.basename(arg) + '.ts';
console.log(`${arg} => ${outpath}`);
writePoFile(arg, outpath, false);
}

function writePoFile(inpath, outpath, nostrip) {
const poData = parser.parse(
fs.readFileSync(inpath).toString().normalize(),
);
const messages = utils.iterateTranslations(poData.translations);
if (!nostrip) {
const header = messages.next().value;
delete header.comments;
for (const msg of messages) {
delete msg.comments;
}
}
const outstream = fs.createWriteStream(outpath, {flags: 'w'});
outstream.write('export default ');
outstream.write(JSON.stringify(utils.convert2Compact(poData), null, 0));
outstream.end();
}
1 change: 1 addition & 0 deletions src/HebrewDateEvent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {HDate, gematriya, months, Locale} from '@hebcal/hdate';
import {Event, flags} from './event';
import '../src/locale'; // Adds Hebrew and Ashkenazic translations

/** Daily Hebrew date ("11th of Sivan, 5780") */
export class HebrewDateEvent extends Event {
Expand Down
1 change: 1 addition & 0 deletions src/HolidayEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {HDate, Locale, isoDateString} from '@hebcal/hdate';
import {Event, flags} from './event';
import {TimedEvent} from './TimedEvent';
import {holidayDesc as hdesc} from './staticHolidays';
import '../src/locale'; // Adds Hebrew and Ashkenazic translations

const minorHolidays = [
hdesc.LAG_BAOMER,
Expand Down
1 change: 1 addition & 0 deletions src/MevarchimChodeshEvent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {HDate, Locale, months} from '@hebcal/hdate';
import {Event, flags} from './event';
import {Molad} from './molad';
import '../src/locale'; // Adds Hebrew and Ashkenazic translations

const mevarchimChodeshStr = 'Shabbat Mevarchim Chodesh';

Expand Down
1 change: 1 addition & 0 deletions src/ParshaEvent.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import {Event, flags} from './event';
import {HDate, Locale, isoDateString} from '@hebcal/hdate';
import '../src/locale'; // Adds Hebrew and Ashkenazic translations

/**
* Represents one of 54 weekly Torah portions, always on a Saturday
Expand Down
1 change: 1 addition & 0 deletions src/TimedEvent.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { Location } from './location';
import { Event } from './event';
import { reformatTimeStr } from './reformatTimeStr';
import { Zmanim } from './zmanim';
import '../src/locale'; // Adds Hebrew and Ashkenazic translations

/** An event that has an `eventTime` and `eventTimeStr` */
export class TimedEvent extends Event {
Expand Down
1 change: 1 addition & 0 deletions src/YomKippurKatanEvent.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import {HDate, Locale} from '@hebcal/hdate';
import {flags} from './event';
import {HolidayEvent} from './HolidayEvent';
import '../src/locale'; // Adds Hebrew and Ashkenazic translations

export const ykk = 'Yom Kippur Katan';

Expand Down
1 change: 1 addition & 0 deletions src/event.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import {HDate, Locale} from '@hebcal/hdate';
import '../src/locale'; // Adds Hebrew and Ashkenazic translations

/**
* Holiday flags for Event
Expand Down
3 changes: 2 additions & 1 deletion src/hebcal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,11 @@
import {
getBirthdayHD, getYahrzeitHD, greg, months,
HDate, Locale,
Sedra,
} from '@hebcal/hdate';
import '../src/locale'; // Adds Hebrew and Ashkenazic translations
import {CalOptions} from './CalOptions';
import {version as pkgVersion} from './pkgVersion';
import {Sedra} from './sedra';
import {DailyLearning} from './DailyLearning';
import {HebrewDateEvent} from './HebrewDateEvent';
import {ParshaEvent} from './ParshaEvent';
Expand Down
3 changes: 2 additions & 1 deletion src/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export {gematriya, gematriyaStrToNum} from '@hebcal/hdate';
export {greg, months, HDate, Locale} from '@hebcal/hdate';
import './locale'; // Adds Hebrew and Ashkenazic translations
export {CalOptions} from './CalOptions';
export {HebrewDateEvent} from './HebrewDateEvent';
export {Event, flags} from './event';
Expand All @@ -9,7 +10,7 @@ export {Zmanim} from './zmanim';
export {TimedEvent, CandleLightingEvent, HavdalahEvent} from './TimedEvent';
export {Molad, MoladEvent} from './molad';
export {OmerEvent} from './omer';
export {Sedra, parshiot} from '@hebcal/hdate';
export {Sedra, parshiot} from './sedra';
export {ParshaEvent} from './ParshaEvent';
export {HolidayEvent, AsaraBTevetEvent,
RoshChodeshEvent, RoshHashanaEvent} from './HolidayEvent';
Expand Down
20 changes: 20 additions & 0 deletions src/locale.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import {Locale, LocaleData, StringArrayMap} from '@hebcal/hdate';
import poAshkenazi from './ashkenazi.po';
import poHe from './he.po';

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

/* Hebrew without nikkud */
const heStrs = poHe.contexts[''];
const heNoNikud: StringArrayMap = {};
for (const [key, val] of Object.entries(heStrs)) {
heNoNikud[key] = [Locale.hebrewStripNikkud(val[0])];
}
const poHeNoNikud: LocaleData = {
headers: poHe.headers,
contexts: {'': heNoNikud},
};
Locale.addTranslations('he-x-NoNikud', poHeNoNikud);
1 change: 1 addition & 0 deletions src/molad.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {Event, flags} from './event';
import {CalOptions} from './CalOptions';
import {HDate, Locale, molad, Molad as MoladBase} from '@hebcal/hdate';
import {reformatTimeStr} from './reformatTimeStr';
import '../src/locale'; // Adds Hebrew and Ashkenazic translations

const shortDayNames = ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
const heDayNames = ['רִאשׁוֹן', 'שֵׁנִי', 'שְׁלִישִׁי', 'רְבִיעִי', 'חֲמִישִׁי', 'שִׁישִּׁי', 'שַׁבָּת'];
Expand Down
1 change: 1 addition & 0 deletions src/omer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import {
omerTodayIs
} from '@hebcal/hdate';
import {Event, flags} from './event';
import '../src/locale'; // Adds Hebrew and Ashkenazic translations

/** Represents a day 1-49 of counting the Omer from Pesach to Shavuot */
export class OmerEvent extends Event {
Expand Down
Loading

0 comments on commit d8a81f3

Please sign in to comment.