Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How does one get the Sedra name in Hebrew? #5

Closed
majortom64 opened this issue Jul 7, 2020 · 2 comments
Closed

How does one get the Sedra name in Hebrew? #5

majortom64 opened this issue Jul 7, 2020 · 2 comments

Comments

@majortom64
Copy link
Contributor

All the ways I try to generate it render it in English.

@mjradwin
Copy link
Member

mjradwin commented Jul 7, 2020

It looks like Sedra.getString() doesn't implement translations as the documentation says. I'll need to clarify.

Here are two options for now:

  1. If you're using the simple interface, specify locale as part of options:
import {HebrewCalendar} from '@hebcal/core';
const options = {
  locale: 'he',
  sedrot: true,
  noHolidays: true,
};
const events = HebrewCalendar.calendar(options);
for (const ev of events) {
  const hd = ev.getDate();
  const date = hd.greg();
  console.log(date.toLocaleDateString(), ev.render());
}
  1. If you want to use the lower-level Sedra API, you can do this:
import {Locale, Sedra, ParshaEvent} from '@hebcal/core';
// specify default locale so you don't need to pass a locale argument to render()
Locale.useLocale('he'); 
const sedra = new Sedra(5780, true);
const hd = new HDate(new Date(2020, 6, 7));
const parsha = sedra.get(hd);
const ev = new ParshaEvent(hd, parsha);
console.log(ev.render());

@mjradwin
Copy link
Member

mjradwin commented Jul 7, 2020

OK, we've published @hebcal/core@2.0.2 which adds locale-awareness to Sedra.getString() without having to use the ParshaEvent workaround.

const {Locale, Sedra, HDate} = require('@hebcal/core');
Locale.useLocale('he'); 
const sedra = new Sedra(5781, false);
console.log(sedra.getString(new HDate(new Date(2021, 3, 24))));
// פרשת אַחֲרֵי מוֹת־קְדשִׁים

@mjradwin mjradwin closed this as completed Jul 7, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants