Package Exports
- hebrew-transliteration
- hebrew-transliteration/package.json
- hebrew-transliteration/removeOptions
- hebrew-transliteration/schemas
Readme
hebrew-transliteration
A JavaScript package for transliterating Hebrew
install
npm
npm install hebrew-transliterationlocal
You will need to have node installed.
Download or clone this repository
cd hebrew-transliteration
npm install
npm run buildexample
const heb = require("hebrew-transliteration");
const transliterate = heb.transliterate;
transliterate("אֱלֹהִים");
// ʾĕlōhîmDOCS
About
This is a JavaScript package for transliterating Hebrew.
It exports 3 functions:
transliterate()— the main function which transliterates Hebrewremove()— removes taamim and optionally removes certain niqqudimsequence()— sequences Hebrew characters according to the SBL Hebrew Font Manual
And it exports 2 classes:
Functions
transliterate()
Takes a string or Text, and optionally a Schema or Partial<Schema>
heb.transliterate("אֱלֹהִים");
// ʾĕlōhîmIf no Schema is passed, then the package defaults to SBL's academic style.
You can pass in a Partial<Schema> that will modify SBL's academic style:
heb.transliterate("שָׁלוֹם", { SHIN: "sh" });
// shālômThere are premade schemas as well.
const brillAcademic = require("hebrew-transliteration/schemas").brillAcademic;
heb.transliterate("בְּבֵית", brillAcademic)
// bᵉḇêṯNote: schemas are not endorsed by publishers.
If you need a fully customized transliteration, it is best to use the Schema constructor:
const schema = new heb.Schema({
ALEF: "'",
BET: "B",
...
QAMETS: "A",
...
}) // truncated for brevity
heb.transliterate("אָ֣ב", schema)
// 'ABremove()
Takes string and RemoveOptions.
The default removes accents (i.e. characters called HEBREW ACCENT) and metheg and rafe.
heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔");
// שָׂרַי אִשְׁתְּךָ;The RemoveOptions can be customized.
heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔", { SHIN_DOT: true, SIN_DOT: true });
// שָרַ֣י אִשְתְּךָ֔Note: unlike a Schema where a Partial<Schema> extends the default, RemoveOptions does not accept a Partial<RemoveOptions>.
All properties for RemoveOptions can be found in the source.
There are some preset options availables as well.
const opts = require("hebrew-transliteration/removeOptions");
heb.remove("שָׂרַ֣י אִשְׁתְּךָ֔", opts.all);
// שרי אשתך, וימצאוsequence()
Takes a string. Returns a string of properly sequenced characters according to the SBL Hebrew Font manual following the pattern of: consonant - dagesh - vowel - ta'am
heb.sequence("\u{5D1}\u{5B0}\u{5BC}\u{5E8}\u{5B5}\u{5D0}\u{5E9}\u{5B4}\u{5C1}\u{596}\u{5D9}\u{5EA}");
// "\u{5D1}\u{5BC}\u{5B0}\u{5E8}\u{5B5}\u{5D0}\u{5E9}\u{5C1}\u{5B4}\u{596}\u{5D9}\u{5EA}"Classes
Text
The Text class from the havarotjs package.
This class is used by transliterate() internally to syllabify Hebrew text, but it is exposed as well.
const text = new heb.Text("הֲבָרֹות");
text.syllables;
// [
// Syllable { original: "הֲ" },
// Syllable { original: "בָ" },
// Syllable { original: "רֹות" }
// ]If a Text is passed into transliterate() instead of a string, then the syllabification from the Text class is used.
If a string is passed in, then syllabification come from the options passed into the Schema.
See more under syllabification.
Schema
A Schema is used to define a schema for transliteration. See the Schema source for all available properties.
The Schema can be divided into a few categories.
1) Syllabification
The options used for syllabifying Hebrew text can be found here
Differences between Text and Schema
There are 5 options for syllabification that are the same as the ones used by the Text class.
Read more about the syllabification options for the Text and a higher level overview
Precedence of Text over Schema
The syllabification options set by Schema are used if a string is passed into transliterate(). If a Text is passed into transliterate() instead of a string, then the syllabification from the Text class is used:
// using default
heb.transliterate("חָכְמָ֣ה"); // ḥokmâ
// using Schema for syllabification
heb.transliterate("חָכְמָ֣ה", { qametsQatan: false }); // ḥākǝmâ
// using Text for syllabification
heb.transliterate(new heb.Text("חָכְמָ֣ה", { qametsQatan: false })); // ḥākǝmâ
// using Schema and Text — Text takes precedence
heb.transliterate(new heb.Text("חָכְמָ֣ה", { qametsQatan: true }), { qametsQatan: false }); // ḥokmâNote: qametsQatan only converts a regular qamets character; if a qamets qatan character is used, it will always be a qamets qatan.
2) Characters
Most Schema properties are for defining single Hebrew characters:
heb.transliterate("אָ", { ALEF: "@", QAMETS: "A" });
// @A3) Orthographic Features
Some properties are for defining common Hebrew orthographies for:
BeGaDKePhaT
There are properties for the digraphs of BeGaDKePhaT letters:
BET_DAGESHGIMEL_DAGESHDALET_DAGESHKAF_DAGESHPE_DAGESHTAV_DAGESH
Each one is the consonant character followed by the dagesh character (U+05BC).
These are helpful for distinguishing between spirantized forms.
heb.transliterate("בְּבֵית", { BET: "b" });
// bǝbêt
heb.transliterate("בְּבֵית", { BET: "v", BET_DAGESH: "b" });
// bǝvêtMatres Lectionis
The following properties are for matres lectionis:
HIRIQ_YODTSERE_YODSEGOL_YODSHUREQHOLAM_VAVQAMATS_HESEGOL_HETSERE_HE
heb.transliterate("פֶּה", { SEGOL_HE: "é" });
// péOthers
There are other orthographic features:
MS_SUFX— HEBREW LETTER QAMATS (U+05B8) and YOD (U+05D9) and VAV (U+05D5) יו◌ָDIVINE_NAME— the full form of the divine name - יהוהSYLLABLE_SEPARATOR— a syllable separator, usually an empty stringDAGESH_CHAZAQ— if true, repeats the consonant with the dagesh
heb.transliterate("שַׁבָּת", { DAGESH_CHAZAQ: true });
// šabbāt
heb.transliterate("שַׁבָּת", { DAGESH_CHAZAQ: false });
// šabāt
heb.transliterate("הָאָֽרֶץ", { SYLLABLE_SEPARATOR: "-" });
// hā-ʾā-reṣ4) Others
Additional Features
The ADDITIONAL_FEATURES property is for defining non-typical Hebrew orthography, example:
heb.transliterate("הַזֹּאת", {
ADDITIONAL_FEATURES: [
{
FEATURE: "cluster",
HEBREW: "זּ",
TRANSLITERATION: "tz"
}
]
});
// hatzōʾt- The orthography
זּis most often a doubling of theZAYIN(i.e.'z'with no dagesh, and'zz'with a dagesh chazaq) - In the Romaniote reading tradition, however, the
ZAYINis usually transliterated with'z'(really'ζ'), - but a
ZAYINfollowed by a dagesh is transliterated as'tz'(really'τζ')
Each additional feature consists of 3 parts:
FEATURE— has three options:
"cluster"— aclusteris any combination of a single character and optionally a dagesh and vowel."syllable"— asyllableis any combination of a multiple characters and a single vowel and optionally a dagesh"word"— covers everything else
HEBREW— the Hebrew text to be transliteratedTRANSLITERATION— the text used to transliterate the Hebrew text
⚠️ this is an experimental property; results may not always meet expectations
Stress Marker
The STRESS_MARKER property is an optional mark to indicate stress in transliteration.
heb.transliterate("מֶ֣לֶךְ", { STRESS_MARKER: { location: "after-vowel", mark: "\u0301" } });
// mélekThe location has four options:
"before-syllable""after-syllable""before-vowel""after-vowel"
A combining mark (e.g. "\u0301") placed "after-vowel" will print on top of the vowel, and placed after a digraph will print on the second vowel.
heb.transliterate("בֵּ֣ית", {
TSERE_YOD: "ei",
STRESS_MARKER: { location: "after-vowel", mark: "\u0301" }
});
// beítLive
Use it live at https://hebrewtransliteration.app
Contributing
See contributing