@hebcal/core 4.0.3 → 4.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/greg0.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.0.3 */
1
+ /*! @hebcal/core v4.1.0 */
2
2
  /*
3
3
  * More minimal greg routines
4
4
  */
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.0.3 */
1
+ /*! @hebcal/core v4.1.0 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -495,12 +495,70 @@ var Locale = /*#__PURE__*/function () {
495
495
  }, {
496
496
  key: "addLocale",
497
497
  value: function addLocale(locale, data) {
498
+ if (typeof locale !== 'string') {
499
+ throw new TypeError("Invalid locale name: ".concat(locale));
500
+ }
498
501
  if (_typeof(data.contexts) !== 'object' || _typeof(data.contexts['']) !== 'object') {
499
502
  throw new TypeError("Locale '".concat(locale, "' invalid compact format"));
500
503
  }
501
504
  locales[locale.toLowerCase()] = data.contexts[''];
502
505
  }
503
506
 
507
+ /**
508
+ * Adds a translation to `locale`, replacing any previous translation.
509
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
510
+ * @param {string} id Message ID to translate
511
+ * @param {string} translation Translation text
512
+ */
513
+ }, {
514
+ key: "addTranslation",
515
+ value: function addTranslation(locale, id, translation) {
516
+ if (typeof locale !== 'string') {
517
+ throw new TypeError("Invalid locale name: ".concat(locale));
518
+ }
519
+ var locale0 = locale.toLowerCase();
520
+ var loc = locales[locale0];
521
+ if (!loc) {
522
+ throw new TypeError("Unknown locale: ".concat(locale));
523
+ }
524
+ if (typeof id !== 'string' || id.length === 0) {
525
+ throw new TypeError("Invalid id: ".concat(id));
526
+ }
527
+ var isArray = Array.isArray(translation);
528
+ if (isArray) {
529
+ var t0 = translation[0];
530
+ if (typeof t0 !== 'string' || t0.length === 0) {
531
+ throw new TypeError("Invalid translation array: ".concat(translation));
532
+ }
533
+ } else if (typeof translation !== 'string') {
534
+ throw new TypeError("Invalid translation: ".concat(translation));
535
+ }
536
+ loc[id] = isArray ? translation : [translation];
537
+ }
538
+ /**
539
+ * Adds multiple translations to `locale`, replacing any previous translations.
540
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
541
+ * @param {LocaleData} data parsed data from a `.po` file.
542
+ */
543
+ }, {
544
+ key: "addTranslations",
545
+ value: function addTranslations(locale, data) {
546
+ if (typeof locale !== 'string') {
547
+ throw new TypeError("Invalid locale name: ".concat(locale));
548
+ }
549
+ var locale0 = locale.toLowerCase();
550
+ var loc = locales[locale0];
551
+ if (!loc) {
552
+ throw new TypeError("Unknown locale: ".concat(locale));
553
+ }
554
+ if (_typeof(data.contexts) !== 'object' || _typeof(data.contexts['']) !== 'object') {
555
+ throw new TypeError("Locale '".concat(locale, "' invalid compact format"));
556
+ }
557
+ var ctx = data.contexts[''];
558
+ Object.keys(ctx).forEach(function (id) {
559
+ loc[id] = ctx[id];
560
+ });
561
+ }
504
562
  /**
505
563
  * Activates a locale. Throws an error if the locale has not been previously added.
506
564
  * After setting the locale to be used, all strings marked for translations
@@ -1890,7 +1948,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
1890
1948
  return new HDate(day, month, hyear);
1891
1949
  }
1892
1950
 
1893
- var version="4.0.3";
1951
+ var version="4.1.0";
1894
1952
 
1895
1953
  var headers={"plural-forms":"nplurals=2; plural=(n > 1);"};var contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
1896
1954
 
@@ -1,2 +1,2 @@
1
- /*! @hebcal/core v4.0.3 */
2
- var hebcal=function(e){"use strict";function t(e){switch(e){case 1:return"א";case 2:return"ב";case 3:return"ג";case 4:return"ד";case 5:return"ה";case 6:return"ו";case 7:return"ז";case 8:return"ח";case 9:return"ט";case 10:return"י";case 20:return"כ";case 30:return"ל";case 40:return"מ";case 50:return"נ";case 60:return"ס";case 70:return"ע";case 80:return"פ";case 90:return"צ";case 100:return"ק";case 200:return"ר";case 300:return"ש";case 400:return"ת";default:return"*INVALID*"}}function r(e){for(var t=[];e>0;){if(15===e||16===e){t.push(9),t.push(e-9);break}var r=100,n=void 0;for(n=400;n>e;n-=r)n===r&&(r/=10);t.push(n),e-=n}return t}function n(e){var n=parseInt(e,10);if(!n)throw new TypeError("invalid parameter to gematriya ".concat(e));var a="",o=Math.floor(n/1e3);if(o>0&&5!==o){for(var u=r(o),i=0;i<u.length;i++)a+=t(u[i]);a+="׳"}var s=r(n%1e3);if(1==s.length)return a+t(s[0])+"׳";for(var c=0;c<s.length;c++)c+1===s.length&&(a+="״"),a+=t(s[c]);return a}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(a=n.key,o=void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?o:String(o)),n)}var a,o}function i(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var s=[0,31,28,31,30,31,30,31,31,30,31,30,31],c=[s,s.slice()];function h(e,t){return e-t*Math.floor(e/t)}function l(e,t){return Math.floor(e/t)}function f(e){return!(e%4||!(e%100)&&e%400)}function y(e){return"object"===a(e)&&Date.prototype===e.__proto__}function v(e){if(!y(e))throw new TypeError("Argument not a Date: ".concat(e));return d(e.getFullYear(),e.getMonth()+1,e.getDate())}function d(e,t,r){var n=e-1;return 365*n+l(n,4)-l(n,100)+l(n,400)+l(367*t-362,12)+(t<=2?0:f(e)?-1:-2)+r}function m(e){if("number"!=typeof e)throw new TypeError("Argument not a Number: ".concat(e));var t=function(e){var t=e-1,r=l(t,146097),n=h(t,146097),a=l(n,36524),o=h(n,36524),u=l(o,1461),i=l(h(o,1461),365),s=400*r+100*a+4*u+i;return 4!=a&&4!=i?s+1:s}(e=Math.trunc(e)),r=l(12*(e-d(t,1,1)+(e<d(t,3,1)?0:f(t)?1:2))+373,367),n=e-d(t,r,1)+1,a=new Date(t,r-1,n);return t<100&&t>=0&&a.setFullYear(t),a}c[1][2]=29;var g={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:f,daysInMonth:function(e,t){return c[+f(t)][e]},isDate:y,dayOfYear:function(e){if(!y(e))throw new TypeError("Argument not a Date: ".concat(e));var t=e.getMonth(),r=e.getDate()+31*t;return t>1&&(r-=Math.floor((4*(t+1)+23)/10),f(e.getFullYear())&&r++),r},greg2abs:v,abs2greg:m},b={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},w={h:"he",a:"ashkenazi",s:"en","":"en"},p=Object.create(null),k=null,A=null,I=function(){function e(){o(this,e)}return i(e,null,[{key:"lookupTranslation",value:function(e,t){var r=t&&t.toLowerCase(),n=("string"==typeof t&&p[r]||k)[e];if(n&&n.length&&n[0].length)return n[0]}},{key:"gettext",value:function(e,t){var r=this.lookupTranslation(e,t);return void 0===r?e:r}},{key:"addLocale",value:function(e,t){if("object"!==a(t.contexts)||"object"!==a(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));p[e.toLowerCase()]=t.contexts[""]}},{key:"useLocale",value:function(e){var t=e.toLowerCase(),r=p[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return A=w[t]||t,k=r}},{key:"getLocaleName",value:function(){return A}},{key:"getLocaleNames",value:function(){return Object.keys(p).sort()}},{key:"ordinal",value:function(e,t){var r=t&&t.toLowerCase()||A;if(!r)return this.getEnOrdinal(e);switch(r){case"en":case"s":case"a":case"ashkenazi":case"ashkenazi_litvish":case"ashkenazi_poylish":case"ashkenazi_standard":return this.getEnOrdinal(e);case"es":return e+"º";case"h":case"he":case"he-x-nonikud":return String(e);default:return e+"."}}},{key:"getEnOrdinal",value:function(e){var t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}},{key:"hebrewStripNikkud",value:function(e){return e.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}}]),e}();I.addLocale("en",b),I.addLocale("s",b),I.addLocale("",b),I.useLocale("en");var N=1,E=2,T=4,D=6,M=7,S=8,L=9,Y=10,H=12,R=13,V={NISAN:1,IYYAR:2,SIVAN:3,TAMUZ:4,AV:5,ELUL:6,TISHREI:7,CHESHVAN:8,KISLEV:9,TEVET:10,SHVAT:11,ADAR_I:12,ADAR_II:13},O=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],F=[O.concat(["Adar","Nisan"]),O.concat(["Adar I","Adar II","Nisan"])],_=Object.create(null),C=-1373428,x=365.24682220597794;function j(e,t){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter '".concat(t,"' not a number: ").concat(e))}function z(e,t,r){if(j(e,"year"),j(t,"month"),j(r,"day"),e<1)throw new RangeError("hebrew2abs: invalid year ".concat(e));var n=r;if(t<M){for(var a=M;a<=P(e);a++)n+=J(a,e);for(var o=N;o<t;o++)n+=J(o,e)}else for(var u=M;u<t;u++)n+=J(u,e);return C+$(e)+n-1}function U(e){return C+$(e)}function K(e){if(j(e,"abs"),(e=Math.trunc(e))<=C)throw new RangeError("abs2hebrew: ".concat(e," is before epoch"));for(var t=Math.floor((e-C)/x);U(t)<=e;)++t;for(var r=e<z(--t,1,1)?7:1;e>z(t,r,J(r,t));)++r;return{yy:t,mm:r,dd:1+e-z(t,r,1)}}function B(e){return(1+7*e)%19<7}function P(e){return 12+B(e)}function J(e,t){switch(e){case E:case T:case D:case Y:case R:return 29}return e===H&&!B(t)||e===S&&!G(t)||e===L&&Q(t)?29:30}function Z(e,t){if(j(e,"month"),j(t,"year"),e<1||e>14)throw new TypeError("bad month argument ".concat(e));return F[+B(t)][e]}function $(e){var t=_[e]=_[e]||function(e){var t=e-1,r=235*Math.floor(t/19)+t%19*12+Math.floor((t%19*7+1)/19),n=204+r%1080*793,a=5+12*r+793*Math.floor(r/1080)+Math.floor(n/1080),o=n%1080+a%24*1080,u=1+29*r+Math.floor(a/24),i=u+(o>=19440||2==u%7&&o>=9924&&!B(e)||1==u%7&&o>=16789&&B(t));return i+(i%7==0||i%7==3||i%7==5)}(e);return t}function q(e){return $(e+1)-$(e)}function G(e){return q(e)%10==5}function Q(e){return q(e)%10==3}function W(e){throw new TypeError(e)}var X="day",ee="week",te="month",re="year",ne={d:X,w:ee,M:te,y:re},ae={day:X,week:ee,month:te,year:re},oe=function(){function e(t,r,n){if(o(this,e),2==arguments.length||arguments.length>3)throw new TypeError("HDate constructor requires 0, 1 or 3 arguments");if(3==arguments.length){if(this.day=this.month=1,n=parseInt(n,10),isNaN(n))throw new TypeError("HDate called with bad year argument: ".concat(n));if(this.year=n,this.setMonth(r),t=parseInt(t,10),isNaN(t))throw new TypeError("HDate called with bad day argument: ".concat(t));this.setDate(t)}else{void 0===t&&(t=new Date);var a="number"!=typeof t||isNaN(t)?y(t)?v(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:W("HDate called with bad argument: ".concat(t)):t,u="number"==typeof a,i=u?K(a):a;this.day=i.dd,this.month=i.mm,this.year=i.yy,u&&(this.abs0=a)}}return i(e,[{key:"getFullYear",value:function(){return this.year}},{key:"isLeapYear",value:function(){return B(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var e=P(this.getFullYear());return(this.getMonth()+e-6)%e||e}},{key:"daysInMonth",value:function(){return J(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return h(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,ue(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),ue(this),this}},{key:"setDate",value:function(e){return this.day=e,ue(this),this}},{key:"greg",value:function(){return m(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=z(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return Z(this.getMonth(),this.getFullYear())}},{key:"render",value:function(){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||I.getLocaleName(),n=this.getDate(),a=I.gettext(this.getMonthName(),r),o=I.ordinal(n,r),u=e.getDayOfTranslation(r),i="".concat(o).concat(u," ").concat(a);if(t){var s=this.getFullYear();return"".concat(i,", ").concat(s)}return i}},{key:"renderGematriya",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getDate(),r=e?"he-x-NoNikud":"he",a=I.gettext(this.getMonthName(),r),o=this.getFullYear();return n(t)+" "+a+" "+n(o)}},{key:"before",value:function(e){return se(e,this,-1)}},{key:"onOrBefore",value:function(e){return se(e,this,0)}},{key:"nearest",value:function(e){return se(e,this,3)}},{key:"onOrAfter",value:function(e){return se(e,this,6)}},{key:"after",value:function(e){return se(e,this,7)}},{key:"next",value:function(){return new e(this.abs()+1)}},{key:"prev",value:function(){return new e(this.abs()-1)}},{key:"add",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(t=parseInt(t,10)))return new e(this);if((r=e.standardizeUnits(r))===X)return new e(this.abs()+t);if(r===ee)return new e(this.abs()+7*t);if(r===re)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===te){var n=new e(this),a=t>0?1:-1;t=Math.abs(t);for(var o=0;o<t;o++)n=new e(n.abs()+a*n.daysInMonth());return n}}},{key:"subtract",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";return this.add(-1*e,t)}},{key:"deltaDays",value:function(t){if(!e.isHDate(t))throw new TypeError("Bad argument: ".concat(t));return this.abs()-t.abs()}},{key:"isSameDate",value:function(t){return!!e.isHDate(t)&&(this.year==t.year&&this.month==t.month&&this.day==t.day)}},{key:"toString",value:function(){var e=this.getDate(),t=this.getFullYear(),r=this.getMonthName();return"".concat(e," ").concat(r," ").concat(t)}}],[{key:"hebrew2abs",value:function(e,t,r){return z(e,t,r)}},{key:"abs2hebrew",value:function(e){return K(e)}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=I.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=ne[e]||String(e||"").toLowerCase().replace(/s$/,"");return ae[t]||W("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return B(e)}},{key:"monthsInYear",value:function(e){return P(e)}},{key:"daysInMonth",value:function(e,t){return J(e,t)}},{key:"getMonthName",value:function(e,t){return Z(e,t)}},{key:"monthNum",value:function(t){if("number"==typeof t){if(isNaN(t)||t>14)throw new RangeError("Invalid month number: ".concat(t));return t}return t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57?parseInt(t,10):e.monthFromName(t)}},{key:"daysInYear",value:function(e){return q(e)}},{key:"longCheshvan",value:function(e){return G(e)}},{key:"shortKislev",value:function(e){return Q(e)}},{key:"monthFromName",value:function(e){if("number"==typeof e){if(isNaN(e)||e<1||e>14)throw new RangeError("Invalid month name: ".concat(e));return e}var t=e.toLowerCase();switch(t[0]){case"n":case"נ":if("o"==t[1])break;return V.NISAN;case"i":return V.IYYAR;case"e":return V.ELUL;case"c":case"ח":return V.CHESHVAN;case"k":case"כ":return V.KISLEV;case"s":switch(t[1]){case"i":return V.SIVAN;case"h":return V.SHVAT}case"t":switch(t[1]){case"a":return V.TAMUZ;case"i":return V.TISHREI;case"e":return V.TEVET}break;case"a":switch(t[1]){case"v":return V.AV;case"d":return/(1|[^i]i|a|א)$/i.test(e)?V.ADAR_I:V.ADAR_II}break;case"ס":return V.SIVAN;case"ט":return V.TEVET;case"ש":return V.SHVAT;case"א":switch(t[1]){case"ב":return V.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?V.ADAR_I:V.ADAR_II;case"י":return V.IYYAR;case"ל":return V.ELUL}break;case"ת":switch(t[1]){case"מ":return V.TAMUZ;case"ש":return V.TISHREI}}throw new RangeError("Unable to parse month name: ".concat(e))}},{key:"dayOnOrBefore",value:function(e,t){return t-(t-e)%7}},{key:"isHDate",value:function(e){return null!==e&&"object"===a(e)&&"number"==typeof e.year&&"number"==typeof e.month&&"number"==typeof e.day&&"function"==typeof e.greg&&"function"==typeof e.abs}}]),e}();function ue(e){ie(e),function(e){e.day<1&&(e.month==V.TISHREI&&(e.year-=1),e.day+=J(e.month,e.year),e.month-=1,ue(e));e.day>J(e.month,e.year)&&(e.month===V.ELUL&&(e.year+=1),e.day-=J(e.month,e.year),e.month+=1,ue(e));ie(e)}(e)}function ie(e){e.month!==V.ADAR_II||e.isLeapYear()?e.month<1?(e.month+=P(e.year),e.year-=1,ue(e)):e.month>P(e.year)&&(e.month-=P(e.year),e.year+=1,ue(e)):(e.month-=1,ue(e)),delete e.abs0}function se(e,t,r){return new oe(oe.dayOnOrBefore(e,t.abs()+r))}var ce=V.NISAN,he=V.CHESHVAN,le=V.KISLEV,fe=V.TEVET,ye=V.SHVAT,ve=V.ADAR_I,de=V.ADAR_II;var me={headers:{"plural-forms":"nplurals=2; plural=(n > 1);"},contexts:{"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}}};I.addLocale("he",me),I.addLocale("h",me);var ge=me.contexts[""],be={};return Object.keys(ge).forEach((function(e){be[e]=[I.hebrewStripNikkud(ge[e][0])]})),I.addLocale("he-x-NoNikud",{headers:me.headers,contexts:{"":be}}),e.HDate=oe,e.Locale=I,e.gematriya=n,e.getBirthdayOrAnniversary=function(e,t){var r=oe.isHDate(t)?t:new oe(t),n=r.getFullYear();if(e===n)return r;if(!(e<n)){var a=B(n),o=r.getMonth(),u=r.getDate();return o==ve&&!a||o==de&&a?o=P(e):o!=he||30!=u||G(e)?o==le&&30==u&&Q(e)?(o=fe,u=1):o==ve&&30==u&&a&&!B(e)&&(o=ce,u=1):(o=le,u=1),new oe(u,o,e)}},e.getYahrzeit=function(e,t){var r=oe.isHDate(t)?t:new oe(t),n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(e<=n.yy))return n.mm!=he||30!=n.dd||G(n.yy+1)?n.mm==le&&30==n.dd&&Q(n.yy+1)?n=K(z(e,fe,1)-1):n.mm==de?n.mm=P(e):n.mm!=ve||30!=n.dd||B(e)||(n.dd=30,n.mm=ye):n=K(z(e,le,1)-1),n.mm!=he||30!=n.dd||G(e)?n.mm==le&&30==n.dd&&Q(e)&&(n.mm=fe,n.dd=1):(n.mm=le,n.dd=1),new oe(n.dd,n.mm,e)},e.greg=g,e.months=V,e.version="4.0.3",e}({});
1
+ /*! @hebcal/core v4.1.0 */
2
+ var hebcal=function(e){"use strict";function t(e){switch(e){case 1:return"א";case 2:return"ב";case 3:return"ג";case 4:return"ד";case 5:return"ה";case 6:return"ו";case 7:return"ז";case 8:return"ח";case 9:return"ט";case 10:return"י";case 20:return"כ";case 30:return"ל";case 40:return"מ";case 50:return"נ";case 60:return"ס";case 70:return"ע";case 80:return"פ";case 90:return"צ";case 100:return"ק";case 200:return"ר";case 300:return"ש";case 400:return"ת";default:return"*INVALID*"}}function r(e){for(var t=[];e>0;){if(15===e||16===e){t.push(9),t.push(e-9);break}var r=100,n=void 0;for(n=400;n>e;n-=r)n===r&&(r/=10);t.push(n),e-=n}return t}function n(e){var n=parseInt(e,10);if(!n)throw new TypeError("invalid parameter to gematriya ".concat(e));var a="",o=Math.floor(n/1e3);if(o>0&&5!==o){for(var u=r(o),i=0;i<u.length;i++)a+=t(u[i]);a+="׳"}var c=r(n%1e3);if(1==c.length)return a+t(c[0])+"׳";for(var s=0;s<c.length;s++)s+1===c.length&&(a+="״"),a+=t(c[s]);return a}function a(e){return a="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},a(e)}function o(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function u(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,(a=n.key,o=void 0,"symbol"==typeof(o=function(e,t){if("object"!=typeof e||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var n=r.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(a,"string"))?o:String(o)),n)}var a,o}function i(e,t,r){return t&&u(e.prototype,t),r&&u(e,r),Object.defineProperty(e,"prototype",{writable:!1}),e}var c=[0,31,28,31,30,31,30,31,31,30,31,30,31],s=[c,c.slice()];function h(e,t){return e-t*Math.floor(e/t)}function l(e,t){return Math.floor(e/t)}function f(e){return!(e%4||!(e%100)&&e%400)}function y(e){return"object"===a(e)&&Date.prototype===e.__proto__}function v(e){if(!y(e))throw new TypeError("Argument not a Date: ".concat(e));return d(e.getFullYear(),e.getMonth()+1,e.getDate())}function d(e,t,r){var n=e-1;return 365*n+l(n,4)-l(n,100)+l(n,400)+l(367*t-362,12)+(t<=2?0:f(e)?-1:-2)+r}function m(e){if("number"!=typeof e)throw new TypeError("Argument not a Number: ".concat(e));var t=function(e){var t=e-1,r=l(t,146097),n=h(t,146097),a=l(n,36524),o=h(n,36524),u=l(o,1461),i=l(h(o,1461),365),c=400*r+100*a+4*u+i;return 4!=a&&4!=i?c+1:c}(e=Math.trunc(e)),r=l(12*(e-d(t,1,1)+(e<d(t,3,1)?0:f(t)?1:2))+373,367),n=e-d(t,r,1)+1,a=new Date(t,r-1,n);return t<100&&t>=0&&a.setFullYear(t),a}s[1][2]=29;var g={monthNames:["","January","February","March","April","May","June","July","August","September","October","November","December"],isLeapYear:f,daysInMonth:function(e,t){return s[+f(t)][e]},isDate:y,dayOfYear:function(e){if(!y(e))throw new TypeError("Argument not a Date: ".concat(e));var t=e.getMonth(),r=e.getDate()+31*t;return t>1&&(r-=Math.floor((4*(t+1)+23)/10),f(e.getFullYear())&&r++),r},greg2abs:v,abs2greg:m},w={headers:{"plural-forms":"nplurals=2; plural=(n!=1);"},contexts:{"":{}}},p={h:"he",a:"ashkenazi",s:"en","":"en"},b=Object.create(null),k=null,I=null,A=function(){function e(){o(this,e)}return i(e,null,[{key:"lookupTranslation",value:function(e,t){var r=t&&t.toLowerCase(),n=("string"==typeof t&&b[r]||k)[e];if(n&&n.length&&n[0].length)return n[0]}},{key:"gettext",value:function(e,t){var r=this.lookupTranslation(e,t);return void 0===r?e:r}},{key:"addLocale",value:function(e,t){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));if("object"!==a(t.contexts)||"object"!==a(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));b[e.toLowerCase()]=t.contexts[""]}},{key:"addTranslation",value:function(e,t,r){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));var n=e.toLowerCase(),a=b[n];if(!a)throw new TypeError("Unknown locale: ".concat(e));if("string"!=typeof t||0===t.length)throw new TypeError("Invalid id: ".concat(t));var o=Array.isArray(r);if(o){var u=r[0];if("string"!=typeof u||0===u.length)throw new TypeError("Invalid translation array: ".concat(r))}else if("string"!=typeof r)throw new TypeError("Invalid translation: ".concat(r));a[t]=o?r:[r]}},{key:"addTranslations",value:function(e,t){if("string"!=typeof e)throw new TypeError("Invalid locale name: ".concat(e));var r=e.toLowerCase(),n=b[r];if(!n)throw new TypeError("Unknown locale: ".concat(e));if("object"!==a(t.contexts)||"object"!==a(t.contexts[""]))throw new TypeError("Locale '".concat(e,"' invalid compact format"));var o=t.contexts[""];Object.keys(o).forEach((function(e){n[e]=o[e]}))}},{key:"useLocale",value:function(e){var t=e.toLowerCase(),r=b[t];if(!r)throw new RangeError("Locale '".concat(e,"' not found"));return I=p[t]||t,k=r}},{key:"getLocaleName",value:function(){return I}},{key:"getLocaleNames",value:function(){return Object.keys(b).sort()}},{key:"ordinal",value:function(e,t){var r=t&&t.toLowerCase()||I;if(!r)return this.getEnOrdinal(e);switch(r){case"en":case"s":case"a":case"ashkenazi":case"ashkenazi_litvish":case"ashkenazi_poylish":case"ashkenazi_standard":return this.getEnOrdinal(e);case"es":return e+"º";case"h":case"he":case"he-x-nonikud":return String(e);default:return e+"."}}},{key:"getEnOrdinal",value:function(e){var t=["th","st","nd","rd"],r=e%100;return e+(t[(r-20)%10]||t[r]||t[0])}},{key:"hebrewStripNikkud",value:function(e){return e.replace(/[\u0590-\u05bd]/g,"").replace(/[\u05bf-\u05c7]/g,"")}}]),e}();A.addLocale("en",w),A.addLocale("s",w),A.addLocale("",w),A.useLocale("en");var E=1,T=2,N=4,D=6,L=7,M=8,S=9,Y=10,H=12,R=13,O={NISAN:1,IYYAR:2,SIVAN:3,TAMUZ:4,AV:5,ELUL:6,TISHREI:7,CHESHVAN:8,KISLEV:9,TEVET:10,SHVAT:11,ADAR_I:12,ADAR_II:13},V=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],x=[V.concat(["Adar","Nisan"]),V.concat(["Adar I","Adar II","Nisan"])],C=Object.create(null),F=-1373428,_=365.24682220597794;function j(e,t){if("number"!=typeof e||isNaN(e))throw new TypeError("invalid parameter '".concat(t,"' not a number: ").concat(e))}function z(e,t,r){if(j(e,"year"),j(t,"month"),j(r,"day"),e<1)throw new RangeError("hebrew2abs: invalid year ".concat(e));var n=r;if(t<L){for(var a=L;a<=P(e);a++)n+=J(a,e);for(var o=E;o<t;o++)n+=J(o,e)}else for(var u=L;u<t;u++)n+=J(u,e);return F+$(e)+n-1}function U(e){return F+$(e)}function K(e){if(j(e,"abs"),(e=Math.trunc(e))<=F)throw new RangeError("abs2hebrew: ".concat(e," is before epoch"));for(var t=Math.floor((e-F)/_);U(t)<=e;)++t;for(var r=e<z(--t,1,1)?7:1;e>z(t,r,J(r,t));)++r;return{yy:t,mm:r,dd:1+e-z(t,r,1)}}function B(e){return(1+7*e)%19<7}function P(e){return 12+B(e)}function J(e,t){switch(e){case T:case N:case D:case Y:case R:return 29}return e===H&&!B(t)||e===M&&!G(t)||e===S&&Q(t)?29:30}function Z(e,t){if(j(e,"month"),j(t,"year"),e<1||e>14)throw new TypeError("bad month argument ".concat(e));return x[+B(t)][e]}function $(e){var t=C[e]=C[e]||function(e){var t=e-1,r=235*Math.floor(t/19)+t%19*12+Math.floor((t%19*7+1)/19),n=204+r%1080*793,a=5+12*r+793*Math.floor(r/1080)+Math.floor(n/1080),o=n%1080+a%24*1080,u=1+29*r+Math.floor(a/24),i=u+(o>=19440||2==u%7&&o>=9924&&!B(e)||1==u%7&&o>=16789&&B(t));return i+(i%7==0||i%7==3||i%7==5)}(e);return t}function q(e){return $(e+1)-$(e)}function G(e){return q(e)%10==5}function Q(e){return q(e)%10==3}function W(e){throw new TypeError(e)}var X="day",ee="week",te="month",re="year",ne={d:X,w:ee,M:te,y:re},ae={day:X,week:ee,month:te,year:re},oe=function(){function e(t,r,n){if(o(this,e),2==arguments.length||arguments.length>3)throw new TypeError("HDate constructor requires 0, 1 or 3 arguments");if(3==arguments.length){if(this.day=this.month=1,n=parseInt(n,10),isNaN(n))throw new TypeError("HDate called with bad year argument: ".concat(n));if(this.year=n,this.setMonth(r),t=parseInt(t,10),isNaN(t))throw new TypeError("HDate called with bad day argument: ".concat(t));this.setDate(t)}else{void 0===t&&(t=new Date);var a="number"!=typeof t||isNaN(t)?y(t)?v(t):e.isHDate(t)?{dd:t.day,mm:t.month,yy:t.year}:W("HDate called with bad argument: ".concat(t)):t,u="number"==typeof a,i=u?K(a):a;this.day=i.dd,this.month=i.mm,this.year=i.yy,u&&(this.abs0=a)}}return i(e,[{key:"getFullYear",value:function(){return this.year}},{key:"isLeapYear",value:function(){return B(this.year)}},{key:"getMonth",value:function(){return this.month}},{key:"getTishreiMonth",value:function(){var e=P(this.getFullYear());return(this.getMonth()+e-6)%e||e}},{key:"daysInMonth",value:function(){return J(this.getMonth(),this.getFullYear())}},{key:"getDate",value:function(){return this.day}},{key:"getDay",value:function(){return h(this.abs(),7)}},{key:"setFullYear",value:function(e){return this.year=e,ue(this),this}},{key:"setMonth",value:function(t){return this.month=e.monthNum(t),ue(this),this}},{key:"setDate",value:function(e){return this.day=e,ue(this),this}},{key:"greg",value:function(){return m(this.abs())}},{key:"abs",value:function(){return"number"!=typeof this.abs0&&(this.abs0=z(this.year,this.month,this.day)),this.abs0}},{key:"getMonthName",value:function(){return Z(this.getMonth(),this.getFullYear())}},{key:"render",value:function(){var t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],r=(arguments.length>0&&void 0!==arguments[0]?arguments[0]:null)||A.getLocaleName(),n=this.getDate(),a=A.gettext(this.getMonthName(),r),o=A.ordinal(n,r),u=e.getDayOfTranslation(r),i="".concat(o).concat(u," ").concat(a);if(t){var c=this.getFullYear();return"".concat(i,", ").concat(c)}return i}},{key:"renderGematriya",value:function(){var e=arguments.length>0&&void 0!==arguments[0]&&arguments[0],t=this.getDate(),r=e?"he-x-NoNikud":"he",a=A.gettext(this.getMonthName(),r),o=this.getFullYear();return n(t)+" "+a+" "+n(o)}},{key:"before",value:function(e){return ce(e,this,-1)}},{key:"onOrBefore",value:function(e){return ce(e,this,0)}},{key:"nearest",value:function(e){return ce(e,this,3)}},{key:"onOrAfter",value:function(e){return ce(e,this,6)}},{key:"after",value:function(e){return ce(e,this,7)}},{key:"next",value:function(){return new e(this.abs()+1)}},{key:"prev",value:function(){return new e(this.abs()-1)}},{key:"add",value:function(t){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";if(!(t=parseInt(t,10)))return new e(this);if((r=e.standardizeUnits(r))===X)return new e(this.abs()+t);if(r===ee)return new e(this.abs()+7*t);if(r===re)return new e(this.getDate(),this.getMonth(),this.getFullYear()+t);if(r===te){var n=new e(this),a=t>0?1:-1;t=Math.abs(t);for(var o=0;o<t;o++)n=new e(n.abs()+a*n.daysInMonth());return n}}},{key:"subtract",value:function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"d";return this.add(-1*e,t)}},{key:"deltaDays",value:function(t){if(!e.isHDate(t))throw new TypeError("Bad argument: ".concat(t));return this.abs()-t.abs()}},{key:"isSameDate",value:function(t){return!!e.isHDate(t)&&(this.year==t.year&&this.month==t.month&&this.day==t.day)}},{key:"toString",value:function(){var e=this.getDate(),t=this.getFullYear(),r=this.getMonthName();return"".concat(e," ").concat(r," ").concat(t)}}],[{key:"hebrew2abs",value:function(e,t,r){return z(e,t,r)}},{key:"abs2hebrew",value:function(e){return K(e)}},{key:"getDayOfTranslation",value:function(e){switch(e){case"en":case"s":case"a":case"ashkenazi":return" of"}var t=A.lookupTranslation("of",e);return t?" "+t:"ashkenazi"===e.substring(0,9)?" of":""}},{key:"standardizeUnits",value:function(e){var t=ne[e]||String(e||"").toLowerCase().replace(/s$/,"");return ae[t]||W("Invalid units '".concat(e,"'"))}},{key:"isLeapYear",value:function(e){return B(e)}},{key:"monthsInYear",value:function(e){return P(e)}},{key:"daysInMonth",value:function(e,t){return J(e,t)}},{key:"getMonthName",value:function(e,t){return Z(e,t)}},{key:"monthNum",value:function(t){if("number"==typeof t){if(isNaN(t)||t>14)throw new RangeError("Invalid month number: ".concat(t));return t}return t.charCodeAt(0)>=48&&t.charCodeAt(0)<=57?parseInt(t,10):e.monthFromName(t)}},{key:"daysInYear",value:function(e){return q(e)}},{key:"longCheshvan",value:function(e){return G(e)}},{key:"shortKislev",value:function(e){return Q(e)}},{key:"monthFromName",value:function(e){if("number"==typeof e){if(isNaN(e)||e<1||e>14)throw new RangeError("Invalid month name: ".concat(e));return e}var t=e.toLowerCase();switch(t[0]){case"n":case"נ":if("o"==t[1])break;return O.NISAN;case"i":return O.IYYAR;case"e":return O.ELUL;case"c":case"ח":return O.CHESHVAN;case"k":case"כ":return O.KISLEV;case"s":switch(t[1]){case"i":return O.SIVAN;case"h":return O.SHVAT}case"t":switch(t[1]){case"a":return O.TAMUZ;case"i":return O.TISHREI;case"e":return O.TEVET}break;case"a":switch(t[1]){case"v":return O.AV;case"d":return/(1|[^i]i|a|א)$/i.test(e)?O.ADAR_I:O.ADAR_II}break;case"ס":return O.SIVAN;case"ט":return O.TEVET;case"ש":return O.SHVAT;case"א":switch(t[1]){case"ב":return O.AV;case"ד":return/(1|[^i]i|a|א)$/i.test(e)?O.ADAR_I:O.ADAR_II;case"י":return O.IYYAR;case"ל":return O.ELUL}break;case"ת":switch(t[1]){case"מ":return O.TAMUZ;case"ש":return O.TISHREI}}throw new RangeError("Unable to parse month name: ".concat(e))}},{key:"dayOnOrBefore",value:function(e,t){return t-(t-e)%7}},{key:"isHDate",value:function(e){return null!==e&&"object"===a(e)&&"number"==typeof e.year&&"number"==typeof e.month&&"number"==typeof e.day&&"function"==typeof e.greg&&"function"==typeof e.abs}}]),e}();function ue(e){ie(e),function(e){e.day<1&&(e.month==O.TISHREI&&(e.year-=1),e.day+=J(e.month,e.year),e.month-=1,ue(e));e.day>J(e.month,e.year)&&(e.month===O.ELUL&&(e.year+=1),e.day-=J(e.month,e.year),e.month+=1,ue(e));ie(e)}(e)}function ie(e){e.month!==O.ADAR_II||e.isLeapYear()?e.month<1?(e.month+=P(e.year),e.year-=1,ue(e)):e.month>P(e.year)&&(e.month-=P(e.year),e.year+=1,ue(e)):(e.month-=1,ue(e)),delete e.abs0}function ce(e,t,r){return new oe(oe.dayOnOrBefore(e,t.abs()+r))}var se=O.NISAN,he=O.CHESHVAN,le=O.KISLEV,fe=O.TEVET,ye=O.SHVAT,ve=O.ADAR_I,de=O.ADAR_II;var me={headers:{"plural-forms":"nplurals=2; plural=(n > 1);"},contexts:{"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}}};A.addLocale("he",me),A.addLocale("h",me);var ge=me.contexts[""],we={};return Object.keys(ge).forEach((function(e){we[e]=[A.hebrewStripNikkud(ge[e][0])]})),A.addLocale("he-x-NoNikud",{headers:me.headers,contexts:{"":we}}),e.HDate=oe,e.Locale=A,e.gematriya=n,e.getBirthdayOrAnniversary=function(e,t){var r=oe.isHDate(t)?t:new oe(t),n=r.getFullYear();if(e===n)return r;if(!(e<n)){var a=B(n),o=r.getMonth(),u=r.getDate();return o==ve&&!a||o==de&&a?o=P(e):o!=he||30!=u||G(e)?o==le&&30==u&&Q(e)?(o=fe,u=1):o==ve&&30==u&&a&&!B(e)&&(o=se,u=1):(o=le,u=1),new oe(u,o,e)}},e.getYahrzeit=function(e,t){var r=oe.isHDate(t)?t:new oe(t),n={yy:r.getFullYear(),mm:r.getMonth(),dd:r.getDate()};if(!(e<=n.yy))return n.mm!=he||30!=n.dd||G(n.yy+1)?n.mm==le&&30==n.dd&&Q(n.yy+1)?n=K(z(e,fe,1)-1):n.mm==de?n.mm=P(e):n.mm!=ve||30!=n.dd||B(e)||(n.dd=30,n.mm=ye):n=K(z(e,le,1)-1),n.mm!=he||30!=n.dd||G(e)?n.mm==le&&30==n.dd&&Q(e)&&(n.mm=fe,n.dd=1):(n.mm=le,n.dd=1),new oe(n.dd,n.mm,e)},e.greg=g,e.months=O,e.version="4.1.0",e}({});
package/dist/hdate.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.0.3 */
1
+ /*! @hebcal/core v4.1.0 */
2
2
  'use strict';
3
3
 
4
4
  const GERESH = '׳';
@@ -438,12 +438,66 @@ class Locale {
438
438
  * @param {LocaleData} data parsed data from a `.po` file.
439
439
  */
440
440
  static addLocale(locale, data) {
441
+ if (typeof locale !== 'string') {
442
+ throw new TypeError(`Invalid locale name: ${locale}`);
443
+ }
441
444
  if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
442
445
  throw new TypeError(`Locale '${locale}' invalid compact format`);
443
446
  }
444
447
  locales[locale.toLowerCase()] = data.contexts[''];
445
448
  }
446
449
 
450
+ /**
451
+ * Adds a translation to `locale`, replacing any previous translation.
452
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
453
+ * @param {string} id Message ID to translate
454
+ * @param {string} translation Translation text
455
+ */
456
+ static addTranslation(locale, id, translation) {
457
+ if (typeof locale !== 'string') {
458
+ throw new TypeError(`Invalid locale name: ${locale}`);
459
+ }
460
+ const locale0 = locale.toLowerCase();
461
+ const loc = locales[locale0];
462
+ if (!loc) {
463
+ throw new TypeError(`Unknown locale: ${locale}`);
464
+ }
465
+ if (typeof id !== 'string' || id.length === 0) {
466
+ throw new TypeError(`Invalid id: ${id}`);
467
+ }
468
+ const isArray = Array.isArray(translation);
469
+ if (isArray) {
470
+ const t0 = translation[0];
471
+ if (typeof t0 !== 'string' || t0.length === 0) {
472
+ throw new TypeError(`Invalid translation array: ${translation}`);
473
+ }
474
+ } else if (typeof translation !== 'string') {
475
+ throw new TypeError(`Invalid translation: ${translation}`);
476
+ }
477
+ loc[id] = isArray ? translation : [translation];
478
+ }
479
+ /**
480
+ * Adds multiple translations to `locale`, replacing any previous translations.
481
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
482
+ * @param {LocaleData} data parsed data from a `.po` file.
483
+ */
484
+ static addTranslations(locale, data) {
485
+ if (typeof locale !== 'string') {
486
+ throw new TypeError(`Invalid locale name: ${locale}`);
487
+ }
488
+ const locale0 = locale.toLowerCase();
489
+ const loc = locales[locale0];
490
+ if (!loc) {
491
+ throw new TypeError(`Unknown locale: ${locale}`);
492
+ }
493
+ if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
494
+ throw new TypeError(`Locale '${locale}' invalid compact format`);
495
+ }
496
+ const ctx = data.contexts[''];
497
+ Object.keys(ctx).forEach(id => {
498
+ loc[id] = ctx[id];
499
+ });
500
+ }
447
501
  /**
448
502
  * Activates a locale. Throws an error if the locale has not been previously added.
449
503
  * After setting the locale to be used, all strings marked for translations
@@ -1747,7 +1801,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
1747
1801
  return new HDate(day, month, hyear);
1748
1802
  }
1749
1803
 
1750
- const version="4.0.3";
1804
+ const version="4.1.0";
1751
1805
 
1752
1806
  const headers={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
1753
1807
 
package/dist/hdate.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.0.3 */
1
+ /*! @hebcal/core v4.1.0 */
2
2
  const GERESH = '׳';
3
3
  const GERSHAYIM = '״';
4
4
 
@@ -438,12 +438,66 @@ class Locale {
438
438
  * @param {LocaleData} data parsed data from a `.po` file.
439
439
  */
440
440
  static addLocale(locale, data) {
441
+ if (typeof locale !== 'string') {
442
+ throw new TypeError(`Invalid locale name: ${locale}`);
443
+ }
441
444
  if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
442
445
  throw new TypeError(`Locale '${locale}' invalid compact format`);
443
446
  }
444
447
  locales[locale.toLowerCase()] = data.contexts[''];
445
448
  }
446
449
 
450
+ /**
451
+ * Adds a translation to `locale`, replacing any previous translation.
452
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
453
+ * @param {string} id Message ID to translate
454
+ * @param {string} translation Translation text
455
+ */
456
+ static addTranslation(locale, id, translation) {
457
+ if (typeof locale !== 'string') {
458
+ throw new TypeError(`Invalid locale name: ${locale}`);
459
+ }
460
+ const locale0 = locale.toLowerCase();
461
+ const loc = locales[locale0];
462
+ if (!loc) {
463
+ throw new TypeError(`Unknown locale: ${locale}`);
464
+ }
465
+ if (typeof id !== 'string' || id.length === 0) {
466
+ throw new TypeError(`Invalid id: ${id}`);
467
+ }
468
+ const isArray = Array.isArray(translation);
469
+ if (isArray) {
470
+ const t0 = translation[0];
471
+ if (typeof t0 !== 'string' || t0.length === 0) {
472
+ throw new TypeError(`Invalid translation array: ${translation}`);
473
+ }
474
+ } else if (typeof translation !== 'string') {
475
+ throw new TypeError(`Invalid translation: ${translation}`);
476
+ }
477
+ loc[id] = isArray ? translation : [translation];
478
+ }
479
+ /**
480
+ * Adds multiple translations to `locale`, replacing any previous translations.
481
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
482
+ * @param {LocaleData} data parsed data from a `.po` file.
483
+ */
484
+ static addTranslations(locale, data) {
485
+ if (typeof locale !== 'string') {
486
+ throw new TypeError(`Invalid locale name: ${locale}`);
487
+ }
488
+ const locale0 = locale.toLowerCase();
489
+ const loc = locales[locale0];
490
+ if (!loc) {
491
+ throw new TypeError(`Unknown locale: ${locale}`);
492
+ }
493
+ if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
494
+ throw new TypeError(`Locale '${locale}' invalid compact format`);
495
+ }
496
+ const ctx = data.contexts[''];
497
+ Object.keys(ctx).forEach((id) => {
498
+ loc[id] = ctx[id];
499
+ });
500
+ }
447
501
  /**
448
502
  * Activates a locale. Throws an error if the locale has not been previously added.
449
503
  * After setting the locale to be used, all strings marked for translations
@@ -1785,7 +1839,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
1785
1839
  return new HDate(day, month, hyear);
1786
1840
  }
1787
1841
 
1788
- const version="4.0.3";
1842
+ const version="4.1.0";
1789
1843
 
1790
1844
  const headers={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts={"":{Adar:["אַדָר"],"Adar I":["אַדָר א׳"],"Adar II":["אַדָר ב׳"],Av:["אָב"],Cheshvan:["חֶשְׁוָן"],Elul:["אֱלוּל"],Iyyar:["אִיָיר"],Kislev:["כִּסְלֵו"],Nisan:["נִיסָן"],"Sh'vat":["שְׁבָט"],Sivan:["סִיוָן"],Tamuz:["תַּמּוּז"],Tevet:["טֵבֵת"],Tishrei:["תִשְׁרֵי"]}};var poHeMin = {headers:headers,contexts:contexts};
1791
1845
 
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.0.3 */
1
+ /*! @hebcal/core v4.1.0 */
2
2
  var hebcal = (function (exports) {
3
3
  'use strict';
4
4
 
@@ -1,2 +1,2 @@
1
- /*! @hebcal/core v4.0.3 */
1
+ /*! @hebcal/core v4.1.0 */
2
2
  var hebcal=function(r){"use strict";function n(r){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(r){return typeof r}:function(r){return r&&"function"==typeof Symbol&&r.constructor===Symbol&&r!==Symbol.prototype?"symbol":typeof r},n(r)}var t=[0,31,28,31,30,31,30,31,31,30,31,30,31];function e(r,n){return r-n*Math.floor(r/n)}function o(r,n){return Math.floor(r/n)}function a(r){return!(r%4||!(r%100)&&r%400)}function u(r,n,t){var e=r-1;return 365*e+o(e,4)-o(e,100)+o(e,400)+o(367*n-362,12)+(n<=2?0:a(r)?-1:-2)+t}[t,t.slice()][1][2]=29;var c=1,f=2,i=4,h=6,s=7,l=8,y=9,b=10,v=12,m=13,p=["","Nisan","Iyyar","Sivan","Tamuz","Av","Elul","Tishrei","Cheshvan","Kislev","Tevet","Sh'vat"],w=[p.concat(["Adar","Nisan"]),p.concat(["Adar I","Adar II","Nisan"])],A=Object.create(null),I=-1373428;function g(r,n){if("number"!=typeof r||isNaN(r))throw new TypeError("invalid parameter '".concat(n,"' not a number: ").concat(r))}function M(r,n,t){if(g(r,"year"),g(n,"month"),g(t,"day"),r<1)throw new RangeError("hebrew2abs: invalid year ".concat(r));var e=t;if(n<s){for(var o=s;o<=d(r);o++)e+=T(o,r);for(var a=c;a<n;a++)e+=T(a,r)}else for(var u=s;u<n;u++)e+=T(u,r);return I+N(r)+e-1}function E(r){return I+N(r)}function S(r){return(1+7*r)%19<7}function d(r){return 12+S(r)}function T(r,n){switch(r){case f:case i:case h:case b:case m:return 29}return r===v&&!S(n)||r===l&&!D(n)||r===y&&R(n)?29:30}function N(r){var n=A[r]=A[r]||function(r){var n=r-1,t=235*Math.floor(n/19)+n%19*12+Math.floor((n%19*7+1)/19),e=204+t%1080*793,o=5+12*t+793*Math.floor(t/1080)+Math.floor(e/1080),a=e%1080+o%24*1080,u=1+29*t+Math.floor(o/24),c=u+(a>=19440||2==u%7&&a>=9924&&!S(r)||1==u%7&&a>=16789&&S(n));return c+(c%7==0||c%7==3||c%7==5)}(r);return n}function Y(r){return N(r+1)-N(r)}function D(r){return Y(r)%10==5}function R(r){return Y(r)%10==3}var V={abs2hebrew:function(r){if(g(r,"abs"),(r=Math.trunc(r))<=I)throw new RangeError("abs2hebrew: ".concat(r," is before epoch"));for(var n=Math.floor((r-I)/365.24682220597794);E(n)<=r;)++n;for(var t=r<M(--n,1,1)?7:1;r>M(n,t,T(t,n));)++t;return{yy:n,mm:t,dd:1+r-M(n,t,1)}},daysInMonth:T,daysInYear:Y,getMonthName:function(r,n){if(g(r,"month"),g(n,"year"),r<1||r>14)throw new TypeError("bad month argument ".concat(r));return w[+S(n)][r]},hebrew2abs:M,isLeapYear:S,longCheshvan:D,months:{NISAN:1,IYYAR:2,SIVAN:3,TAMUZ:4,AV:5,ELUL:6,TISHREI:7,CHESHVAN:8,KISLEV:9,TEVET:10,SHVAT:11,ADAR_I:12,ADAR_II:13},monthsInYear:d,shortKislev:R};return r.abs2greg=function(r){if("number"!=typeof r)throw new TypeError("Argument not a Number: ".concat(r));var n=function(r){var n=r-1,t=o(n,146097),a=e(n,146097),u=o(a,36524),c=e(a,36524),f=o(c,1461),i=o(e(c,1461),365),h=400*t+100*u+4*f+i;return 4!=u&&4!=i?h+1:h}(r=Math.trunc(r)),t=o(12*(r-u(n,1,1)+(r<u(n,3,1)?0:a(n)?1:2))+373,367),c=r-u(n,t,1)+1,f=new Date(n,t-1,c);return n<100&&n>=0&&f.setFullYear(n),f},r.greg2abs=function(r){if("object"!==n(t=r)||Date.prototype!==t.__proto__)throw new TypeError("Argument not a Date: ".concat(r));var t;return u(r.getFullYear(),r.getMonth()+1,r.getDate())},r.hdate=V,r}({});
package/dist/hdate0.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.0.3 */
1
+ /*! @hebcal/core v4.1.0 */
2
2
  /*
3
3
  * More minimal greg routines
4
4
  */
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.0.3 */
1
+ /*! @hebcal/core v4.1.0 */
2
2
  'use strict';
3
3
 
4
4
  /*
@@ -438,12 +438,66 @@ class Locale {
438
438
  * @param {LocaleData} data parsed data from a `.po` file.
439
439
  */
440
440
  static addLocale(locale, data) {
441
+ if (typeof locale !== 'string') {
442
+ throw new TypeError(`Invalid locale name: ${locale}`);
443
+ }
441
444
  if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
442
445
  throw new TypeError(`Locale '${locale}' invalid compact format`);
443
446
  }
444
447
  locales[locale.toLowerCase()] = data.contexts[''];
445
448
  }
446
449
 
450
+ /**
451
+ * Adds a translation to `locale`, replacing any previous translation.
452
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
453
+ * @param {string} id Message ID to translate
454
+ * @param {string} translation Translation text
455
+ */
456
+ static addTranslation(locale, id, translation) {
457
+ if (typeof locale !== 'string') {
458
+ throw new TypeError(`Invalid locale name: ${locale}`);
459
+ }
460
+ const locale0 = locale.toLowerCase();
461
+ const loc = locales[locale0];
462
+ if (!loc) {
463
+ throw new TypeError(`Unknown locale: ${locale}`);
464
+ }
465
+ if (typeof id !== 'string' || id.length === 0) {
466
+ throw new TypeError(`Invalid id: ${id}`);
467
+ }
468
+ const isArray = Array.isArray(translation);
469
+ if (isArray) {
470
+ const t0 = translation[0];
471
+ if (typeof t0 !== 'string' || t0.length === 0) {
472
+ throw new TypeError(`Invalid translation array: ${translation}`);
473
+ }
474
+ } else if (typeof translation !== 'string') {
475
+ throw new TypeError(`Invalid translation: ${translation}`);
476
+ }
477
+ loc[id] = isArray ? translation : [translation];
478
+ }
479
+ /**
480
+ * Adds multiple translations to `locale`, replacing any previous translations.
481
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
482
+ * @param {LocaleData} data parsed data from a `.po` file.
483
+ */
484
+ static addTranslations(locale, data) {
485
+ if (typeof locale !== 'string') {
486
+ throw new TypeError(`Invalid locale name: ${locale}`);
487
+ }
488
+ const locale0 = locale.toLowerCase();
489
+ const loc = locales[locale0];
490
+ if (!loc) {
491
+ throw new TypeError(`Unknown locale: ${locale}`);
492
+ }
493
+ if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
494
+ throw new TypeError(`Locale '${locale}' invalid compact format`);
495
+ }
496
+ const ctx = data.contexts[''];
497
+ Object.keys(ctx).forEach(id => {
498
+ loc[id] = ctx[id];
499
+ });
500
+ }
447
501
  /**
448
502
  * Activates a locale. Throws an error if the locale has not been previously added.
449
503
  * After setting the locale to be used, all strings marked for translations
@@ -5162,7 +5216,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
5162
5216
  return new HDate(day, month, hyear);
5163
5217
  }
5164
5218
 
5165
- var version="4.0.3";
5219
+ var version="4.1.0";
5166
5220
 
5167
5221
  var headers$1={"plural-forms":"nplurals=2; plural=(n > 1);"};var contexts$1={"":{Berachot:["Berachos"],Shabbat:["Shabbos"],Taanit:["Taanis"],Yevamot:["Yevamos"],Ketubot:["Kesubos"],"Baba Batra":["Baba Basra"],Makkot:["Makkos"],Shevuot:["Shevuos"],Horayot:["Horayos"],Menachot:["Menachos"],Bechorot:["Bechoros"],Keritot:["Kerisos"],Midot:["Midos"],"Achrei Mot":["Achrei Mos"],Bechukotai:["Bechukosai"],"Beha'alotcha":["Beha'aloscha"],Bereshit:["Bereshis"],Chukat:["Chukas"],"Erev Shavuot":["Erev Shavuos"],"Erev Sukkot":["Erev Sukkos"],"Ki Tavo":["Ki Savo"],"Ki Teitzei":["Ki Seitzei"],"Ki Tisa":["Ki Sisa"],Matot:["Matos"],"Purim Katan":["Purim Koton"],Tazria:["Sazria"],"Shabbat Chazon":["Shabbos Chazon"],"Shabbat HaChodesh":["Shabbos HaChodesh"],"Shabbat HaGadol":["Shabbos HaGadol"],"Shabbat Nachamu":["Shabbos Nachamu"],"Shabbat Parah":["Shabbos Parah"],"Shabbat Shekalim":["Shabbos Shekalim"],"Shabbat Shuva":["Shabbos Shuvah"],"Shabbat Zachor":["Shabbos Zachor"],Shavuot:["Shavuos"],"Shavuot I":["Shavuos I"],"Shavuot II":["Shavuos II"],Shemot:["Shemos"],"Shmini Atzeret":["Shmini Atzeres"],"Simchat Torah":["Simchas Torah"],Sukkot:["Sukkos"],"Sukkot I":["Sukkos I"],"Sukkot II":["Sukkos II"],"Sukkot II (CH''M)":["Sukkos II (CH''M)"],"Sukkot III (CH''M)":["Sukkos III (CH''M)"],"Sukkot IV (CH''M)":["Sukkos IV (CH''M)"],"Sukkot V (CH''M)":["Sukkos V (CH''M)"],"Sukkot VI (CH''M)":["Sukkos VI (CH''M)"],"Sukkot VII (Hoshana Raba)":["Sukkos VII (Hoshana Raba)"],"Ta'anit Bechorot":["Ta'anis Bechoros"],"Ta'anit Esther":["Ta'anis Esther"],Toldot:["Toldos"],Vaetchanan:["Vaeschanan"],Yitro:["Yisro"],"Vezot Haberakhah":["Vezos Haberakhah"],Parashat:["Parshas"],"Leil Selichot":["Leil Selichos"],"Shabbat Mevarchim Chodesh":["Shabbos Mevorchim Chodesh"],"Shabbat Shirah":["Shabbos Shirah"],Tevet:["Teves"],"Asara B'Tevet":["Asara B'Teves"],Berakhot:["Berakhos"],Sheviit:["Sheviis"],Terumot:["Terumos"],Maasrot:["Maasros"],Eduyot:["Eduyos"],Avot:["Avos"],Bekhorot:["Bekhoros"],Middot:["Middos"],Oholot:["Oholos"],Tahorot:["Tahoros"],Mikvaot:["Mikvaos"],"Alot HaShachar":["Alos HaShachar"],"Kriat Shema, sof zeman":["Krias Shema, sof zman"],"Tefilah, sof zeman":["Tefilah, sof zman"],"Kriat Shema, sof zeman (MGA)":["Krias Shema, sof zman (MGA)"],"Tefilah, sof zeman (MGA)":["Tefilah, sof zman (MGA)"],"Chatzot HaLailah":["Chatzos HaLailah"],"Chatzot hayom":["Chatzos"],"Tzeit HaKochavim":["Tzeis HaKochavim"],"Birkat Hachamah":["Birkas Hachamah"],"Shushan Purim Katan":["Shushan Purim Koton"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
5168
5222
 
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/core v4.0.3 */
1
+ /*! @hebcal/core v4.1.0 */
2
2
  /*
3
3
  * More minimal greg routines
4
4
  */
@@ -436,12 +436,66 @@ class Locale {
436
436
  * @param {LocaleData} data parsed data from a `.po` file.
437
437
  */
438
438
  static addLocale(locale, data) {
439
+ if (typeof locale !== 'string') {
440
+ throw new TypeError(`Invalid locale name: ${locale}`);
441
+ }
439
442
  if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
440
443
  throw new TypeError(`Locale '${locale}' invalid compact format`);
441
444
  }
442
445
  locales[locale.toLowerCase()] = data.contexts[''];
443
446
  }
444
447
 
448
+ /**
449
+ * Adds a translation to `locale`, replacing any previous translation.
450
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
451
+ * @param {string} id Message ID to translate
452
+ * @param {string} translation Translation text
453
+ */
454
+ static addTranslation(locale, id, translation) {
455
+ if (typeof locale !== 'string') {
456
+ throw new TypeError(`Invalid locale name: ${locale}`);
457
+ }
458
+ const locale0 = locale.toLowerCase();
459
+ const loc = locales[locale0];
460
+ if (!loc) {
461
+ throw new TypeError(`Unknown locale: ${locale}`);
462
+ }
463
+ if (typeof id !== 'string' || id.length === 0) {
464
+ throw new TypeError(`Invalid id: ${id}`);
465
+ }
466
+ const isArray = Array.isArray(translation);
467
+ if (isArray) {
468
+ const t0 = translation[0];
469
+ if (typeof t0 !== 'string' || t0.length === 0) {
470
+ throw new TypeError(`Invalid translation array: ${translation}`);
471
+ }
472
+ } else if (typeof translation !== 'string') {
473
+ throw new TypeError(`Invalid translation: ${translation}`);
474
+ }
475
+ loc[id] = isArray ? translation : [translation];
476
+ }
477
+ /**
478
+ * Adds multiple translations to `locale`, replacing any previous translations.
479
+ * @param {string} locale Locale name (i.e: `'he'`, `'fr'`).
480
+ * @param {LocaleData} data parsed data from a `.po` file.
481
+ */
482
+ static addTranslations(locale, data) {
483
+ if (typeof locale !== 'string') {
484
+ throw new TypeError(`Invalid locale name: ${locale}`);
485
+ }
486
+ const locale0 = locale.toLowerCase();
487
+ const loc = locales[locale0];
488
+ if (!loc) {
489
+ throw new TypeError(`Unknown locale: ${locale}`);
490
+ }
491
+ if (typeof data.contexts !== 'object' || typeof data.contexts[''] !== 'object') {
492
+ throw new TypeError(`Locale '${locale}' invalid compact format`);
493
+ }
494
+ const ctx = data.contexts[''];
495
+ Object.keys(ctx).forEach(id => {
496
+ loc[id] = ctx[id];
497
+ });
498
+ }
445
499
  /**
446
500
  * Activates a locale. Throws an error if the locale has not been previously added.
447
501
  * After setting the locale to be used, all strings marked for translations
@@ -5160,7 +5214,7 @@ function getBirthdayOrAnniversary_(hyear, gdate) {
5160
5214
  return new HDate(day, month, hyear);
5161
5215
  }
5162
5216
 
5163
- const version="4.0.3";
5217
+ const version="4.1.0";
5164
5218
 
5165
5219
  const headers$1={"plural-forms":"nplurals=2; plural=(n > 1);"};const contexts$1={"":{Berachot:["Berachos"],Shabbat:["Shabbos"],Taanit:["Taanis"],Yevamot:["Yevamos"],Ketubot:["Kesubos"],"Baba Batra":["Baba Basra"],Makkot:["Makkos"],Shevuot:["Shevuos"],Horayot:["Horayos"],Menachot:["Menachos"],Bechorot:["Bechoros"],Keritot:["Kerisos"],Midot:["Midos"],"Achrei Mot":["Achrei Mos"],Bechukotai:["Bechukosai"],"Beha'alotcha":["Beha'aloscha"],Bereshit:["Bereshis"],Chukat:["Chukas"],"Erev Shavuot":["Erev Shavuos"],"Erev Sukkot":["Erev Sukkos"],"Ki Tavo":["Ki Savo"],"Ki Teitzei":["Ki Seitzei"],"Ki Tisa":["Ki Sisa"],Matot:["Matos"],"Purim Katan":["Purim Koton"],Tazria:["Sazria"],"Shabbat Chazon":["Shabbos Chazon"],"Shabbat HaChodesh":["Shabbos HaChodesh"],"Shabbat HaGadol":["Shabbos HaGadol"],"Shabbat Nachamu":["Shabbos Nachamu"],"Shabbat Parah":["Shabbos Parah"],"Shabbat Shekalim":["Shabbos Shekalim"],"Shabbat Shuva":["Shabbos Shuvah"],"Shabbat Zachor":["Shabbos Zachor"],Shavuot:["Shavuos"],"Shavuot I":["Shavuos I"],"Shavuot II":["Shavuos II"],Shemot:["Shemos"],"Shmini Atzeret":["Shmini Atzeres"],"Simchat Torah":["Simchas Torah"],Sukkot:["Sukkos"],"Sukkot I":["Sukkos I"],"Sukkot II":["Sukkos II"],"Sukkot II (CH''M)":["Sukkos II (CH''M)"],"Sukkot III (CH''M)":["Sukkos III (CH''M)"],"Sukkot IV (CH''M)":["Sukkos IV (CH''M)"],"Sukkot V (CH''M)":["Sukkos V (CH''M)"],"Sukkot VI (CH''M)":["Sukkos VI (CH''M)"],"Sukkot VII (Hoshana Raba)":["Sukkos VII (Hoshana Raba)"],"Ta'anit Bechorot":["Ta'anis Bechoros"],"Ta'anit Esther":["Ta'anis Esther"],Toldot:["Toldos"],Vaetchanan:["Vaeschanan"],Yitro:["Yisro"],"Vezot Haberakhah":["Vezos Haberakhah"],Parashat:["Parshas"],"Leil Selichot":["Leil Selichos"],"Shabbat Mevarchim Chodesh":["Shabbos Mevorchim Chodesh"],"Shabbat Shirah":["Shabbos Shirah"],Tevet:["Teves"],"Asara B'Tevet":["Asara B'Teves"],Berakhot:["Berakhos"],Sheviit:["Sheviis"],Terumot:["Terumos"],Maasrot:["Maasros"],Eduyot:["Eduyos"],Avot:["Avos"],Bekhorot:["Bekhoros"],Middot:["Middos"],Oholot:["Oholos"],Tahorot:["Tahoros"],Mikvaot:["Mikvaos"],"Alot HaShachar":["Alos HaShachar"],"Kriat Shema, sof zeman":["Krias Shema, sof zman"],"Tefilah, sof zeman":["Tefilah, sof zman"],"Kriat Shema, sof zeman (MGA)":["Krias Shema, sof zman (MGA)"],"Tefilah, sof zeman (MGA)":["Tefilah, sof zman (MGA)"],"Chatzot HaLailah":["Chatzos HaLailah"],"Chatzot hayom":["Chatzos"],"Tzeit HaKochavim":["Tzeis HaKochavim"],"Birkat Hachamah":["Birkas Hachamah"],"Shushan Purim Katan":["Shushan Purim Koton"]}};var poAshkenazi = {headers:headers$1,contexts:contexts$1};
5166
5220
 
package/hebcal.d.ts CHANGED
@@ -494,6 +494,19 @@ declare module '@hebcal/core' {
494
494
  * @param data - parsed data from a `.po` file.
495
495
  */
496
496
  static addLocale(locale: string, data: LocaleData): void;
497
+ /**
498
+ * Adds a translation to `locale`, replacing any previous translation.
499
+ * @param locale - Locale name (i.e: `'he'`, `'fr'`).
500
+ * @param id - Message ID to translate
501
+ * @param translation - Translation text
502
+ */
503
+ static addTranslation(locale: string, id: string, translation: string | string[]): void;
504
+ /**
505
+ * Adds multiple translations to `locale`, replacing any previous translations.
506
+ * @param locale - Locale name (i.e: `'he'`, `'fr'`).
507
+ * @param data - parsed data from a `.po` file.
508
+ */
509
+ static addTranslations(locale: string, data: LocaleData): void;
497
510
  /**
498
511
  * Activates a locale. Throws an error if the locale has not been previously added.
499
512
  * After setting the locale to be used, all strings marked for translations
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/core",
3
- "version": "4.0.3",
3
+ "version": "4.1.0",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "contributors": [
6
6
  "Eyal Schachter (https://github.com/Scimonster)",
@@ -67,24 +67,24 @@
67
67
  "verbose": true
68
68
  },
69
69
  "devDependencies": {
70
- "@babel/core": "^7.21.8",
71
- "@babel/preset-env": "^7.21.5",
70
+ "@babel/core": "^7.22.1",
71
+ "@babel/preset-env": "^7.22.4",
72
72
  "@babel/register": "^7.21.0",
73
73
  "@hebcal/solar-calc": "^1.1.2",
74
74
  "@rollup/plugin-babel": "^6.0.3",
75
75
  "@rollup/plugin-commonjs": "^25.0.0",
76
76
  "@rollup/plugin-json": "^6.0.0",
77
- "@rollup/plugin-node-resolve": "^15.0.2",
78
- "@rollup/plugin-terser": "^0.4.1",
79
- "ava": "^5.2.0",
77
+ "@rollup/plugin-node-resolve": "^15.1.0",
78
+ "@rollup/plugin-terser": "^0.4.3",
79
+ "ava": "^5.3.0",
80
80
  "codecov": "^3.8.3",
81
81
  "core-js": "^3.30.2",
82
- "eslint": "^8.40.0",
82
+ "eslint": "^8.42.0",
83
83
  "eslint-config-google": "^0.14.0",
84
84
  "jsdoc": "^4.0.2",
85
85
  "jsdoc-to-markdown": "^8.0.0",
86
86
  "nyc": "^15.1.0",
87
- "rollup": "^3.21.7",
87
+ "rollup": "^3.23.1",
88
88
  "ttag-cli": "^1.10.5"
89
89
  }
90
90
  }