Skip to content

Commit

Permalink
Avoid lexical declaration in case block
Browse files Browse the repository at this point in the history
  • Loading branch information
mjradwin committed Dec 18, 2023
1 parent 55468f2 commit 7b2febf
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 23 deletions.
21 changes: 14 additions & 7 deletions src/HebrewDateEvent.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,24 @@ export class HebrewDateEvent extends Event {
switch (locale0) {
case 'h':
case 'he':
return hd.renderGematriya(false);
case 'he-x-nonikud':
const dd = hd.getDate();
const mm = Locale.gettext(hd.getMonthName(), locale0);
const yy = hd.getFullYear();
return gematriya(dd) + ' ' + mm + ' ' + gematriya(yy);
return hd.renderGematriya(true);
default:
return hd.render(locale0, true);
}
}
/**
* @private
* @param {string} locale
* @return {string}
*/
renderBriefHebrew(locale) {
const hd = this.getDate();
const dd = hd.getDate();
const mm = Locale.gettext(hd.getMonthName(), locale);
return gematriya(dd) + ' ' + mm;
}
/**
* @param {string} [locale] Optional locale name (defaults to active locale).
* @example
Expand All @@ -59,9 +68,7 @@ export class HebrewDateEvent extends Event {
case 'h':
case 'he':
case 'he-x-nonikud':
const dd = hd.getDate();
const mm = Locale.gettext(hd.getMonthName(), locale0);
return gematriya(dd) + ' ' + mm;
return this.renderBriefHebrew(locale0);
default:
return hd.render(locale0, false);
}
Expand Down
48 changes: 32 additions & 16 deletions src/omer.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,24 +44,40 @@ export class OmerEvent extends Event {
* @return {string}
*/
sefira(lang='en') {
const week = sefirot[this.weekNumber];
const dayWithinWeek = sefirot[this.daysWithinWeeks];
switch (lang) {
case 'he':
const heWeek = Locale.gettext(week, 'he');
const heDayWithinWeek = Locale.gettext(dayWithinWeek, 'he');
const hePrefix = this.weekNumber === 2 || this.weekNumber === 6 ? 'שֶׁבִּ' : 'שֶׁבְּ';
return `${heDayWithinWeek} ${hePrefix}${heWeek}`.normalize();
case 'translit':
const translitWeek = sefirotTranslit[this.weekNumber];
const translitDayWithinWeek = sefirotTranslit[this.daysWithinWeeks];
const translitPrefix = this.weekNumber === 2 || this.weekNumber === 6 ? 'shebi' : `sheb'`;
return `${translitDayWithinWeek} ${translitPrefix}${translitWeek}`;
case 'en':
default:
return `${dayWithinWeek} within ${week}`;
if (lang === 'he') {
return this.sefiraHe();
} else if (lang === 'translit') {
return this.sefiraTranslit();
} else {
const week = sefirot[this.weekNumber];
const dayWithinWeek = sefirot[this.daysWithinWeeks];
return `${dayWithinWeek} within ${week}`;
}
}
/**
* @private
* @return {string}
*/
sefiraTranslit() {
const weekNum = this.weekNumber;
const translitWeek = sefirotTranslit[weekNum];
const translitDayWithinWeek = sefirotTranslit[this.daysWithinWeeks];
const translitPrefix = weekNum === 2 || weekNum === 6 ? 'shebi' : `sheb'`;
return `${translitDayWithinWeek} ${translitPrefix}${translitWeek}`;
}
/**
* @private
* @return {string}
*/
sefiraHe() {
const weekNum = this.weekNumber;
const week = sefirot[weekNum];
const dayWithinWeek = sefirot[this.daysWithinWeeks];
const heWeek = Locale.gettext(week, 'he');
const heDayWithinWeek = Locale.gettext(dayWithinWeek, 'he');
const hePrefix = weekNum === 2 || weekNum === 6 ? 'שֶׁבִּ' : 'שֶׁבְּ';
return `${heDayWithinWeek} ${hePrefix}${heWeek}`.normalize();
}
/**
* @todo use gettext()
* @param {string} [locale] Optional locale name (defaults to active locale).
Expand Down

0 comments on commit 7b2febf

Please sign in to comment.