Skip to content

Commit

Permalink
Fix missing translation for rosh hashana (#10)
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Sep 14, 2020
1 parent 08b17c8 commit f09e882
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 7 deletions.
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@hebcal/core",
"version": "2.5.1",
"version": "2.5.2",
"author": "Michael J. Radwin (https://github.com/mjradwin)",
"contributors": [
"Eyal Schachter (https://github.com/Scimonster)",
Expand Down Expand Up @@ -69,21 +69,21 @@
"@babel/preset-env": "^7.11.5",
"@babel/register": "^7.11.5",
"@hebcal/solar-calc": "^1.0.4",
"@rollup/plugin-babel": "^5.2.0",
"@rollup/plugin-babel": "^5.2.1",
"@rollup/plugin-commonjs": "^15.0.0",
"@rollup/plugin-json": "^4.1.0",
"@rollup/plugin-node-resolve": "^9.0.0",
"ava": "^3.12.1",
"core-js": "^3.6.5",
"eslint": "^7.8.1",
"eslint": "^7.9.0",
"eslint-config-google": "^0.14.0",
"gematriya": "^2.0.0",
"jsdoc": "^3.6.5",
"jsdoc-to-markdown": "^6.0.1",
"nyc": "^15.1.0",
"rollup": "^2.26.10",
"rollup": "^2.26.11",
"rollup-plugin-terser": "^7.0.2",
"tsd-jsdoc": "^2.5.0",
"ttag-cli": "^1.8.4"
"ttag-cli": "^1.8.5"
}
}
26 changes: 25 additions & 1 deletion src/hebcal.js
Original file line number Diff line number Diff line change
Expand Up @@ -689,7 +689,7 @@ export const HebrewCalendar = {
}

// standard holidays that don't shift based on year
add(new HolidayEvent(RH, `Rosh Hashana ${year}`, CHAG | LIGHT_CANDLES_TZEIS));
add(new RoshHashanaEvent(RH, year, CHAG | LIGHT_CANDLES_TZEIS));
addEvents(year, [
[2, TISHREI, 'Rosh Hashana II', CHAG | YOM_TOV_ENDS],
[3 + (RH.getDay() == THU),
Expand Down Expand Up @@ -933,3 +933,27 @@ export const HebrewCalendar = {
return `${hour}:${hm[1]}${suffix}`;
},
};

/**
* @private
*/
class RoshHashanaEvent extends HolidayEvent {
/**
* @private
* @param {HDate} date Hebrew date event occurs
* @param {number} hyear Hebrew year
* @param {number} mask optional holiday flags
*/
constructor(date, hyear, mask) {
super(date, `Rosh Hashana ${hyear}`, mask);
this.hyear = hyear;
}
/**
* Returns (translated) description of this event
* @param {string} [locale] Optional locale name (defaults to active locale).
* @return {string}
*/
render(locale) {
return Locale.gettext('Rosh Hashana', locale) + ' ' + this.hyear;
}
}
10 changes: 9 additions & 1 deletion src/hebcal.spec.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import test from 'ava';
import {HebrewCalendar, getStartAndEnd} from './hebcal';
import {HDate} from './hdate';
import {HDate, months} from './hdate';
import {flags} from './event';
import {Location} from './location';

Expand Down Expand Up @@ -200,6 +200,14 @@ test('locale-he', (t) => {
t.is(ev.render(), 'שַׁבָּת הַגָּדוֹל');
});

test('locale-he-rosh-hashana', (t) => {
const RH = new HDate(1, months.TISHREI, 5749);
const options = {start: RH, end: RH};
const ev = HebrewCalendar.calendar(options)[0];
t.is(ev.render('en'), 'Rosh Hashana 5749');
t.is(ev.render('he'), 'רֹאשׁ הַשָּׁנָה 5749');
});

test('addHebrewDatesForEvents', (t) => {
const options0 = {year: 2017, month: 3, noHolidays: true, addHebrewDatesForEvents: true};
const ev0 = HebrewCalendar.calendar(options0);
Expand Down

0 comments on commit f09e882

Please sign in to comment.